On Saturday, July 07, 2012 10:18:08 PM John Kearney wrote:
> eval vars=([black]=night [white]=snow
> $(cat /tmp/xxx) [yellow]=submarine
> [pink]=elephant)
There is an additional pitfall here. While the contents of an assignment
argument are protected from an initial globbing pass:
$ ( touch \* foo bar; eval x=( * ); echo "address@hidden" )
* bar foo
$ ( eval x=\( * \); echo "address@hidden" )
* bar foo bar foo
The assignment argument as a whole is not:
$ ( set -x; touch 'x+=(\[[123]\]=*)' 'x+=([3]=yo)'; eval x+=(*); echo
"address@hidden" )
+ touch 'x+=(\[[123]\]=*)' 'x+=([3]=yo)'
+ eval 'x+=(\[[123]\]=*)' 'x+=([3]=yo)'
++ x+=(\[[123]\]=*)
++ x+=([3]=yo)
+ echo '[[123]]=*' yo
[[123]]=* yo
So although Bash (and only Bash) allows these unescaped array assignments, with
eval, they should be quoted/escaped anyway.
--
Dan Douglas