Greg Wooledge wrote:
NEVER use eval plus a brace expansion to generate a list. That's just
freakin' evil. And unsafe:
===
But I _like_ evil sometimes! >:->
imadev:~$ a=(lib tmp bin share '`date`')
imadev:~$ (export IFS=,;eval "echo /usr/{${a[*]}}")
/usr/lib /usr/tmp /usr/bin /usr/share /usr/Fri Apr 27 08:25:49 EDT 2012
----
There can be lots of such problems... I tried it on larger dirs.. parens
quote...all sorts of probs... tried embedded print "%q" ......etc
But reality is things like that save me time in typing in stuff or writing
maint scripts on my machine -- they aren't meant for handling user input.
They take hand editing to gen the paths I want and don't take user input,
so it's a specialized usage in that case....
Alternative 1:
a=(lib tmp bin share)
echo "${a[@]/#//usr/}"
Alternative 2:
a=(lib tmp bin share)
printf "/usr/%s " "${a[@]}"
---
good points....
But I was pointing out that [*] has its place ... I use [@] alot
more often than [*], but will use [*], though a bit irregularly,
when I want to get the # of items in an array (where either would work)..
though I could make a case if it was worth anything to me that #..@ return
# items and #...[*] return total length of all items... but I don't really
care....and it would break all my usages of #..[*]... ;-)....
C'est la vi...