[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Associative array questions
From: |
Dan Douglas |
Subject: |
Re: [Help-bash] Associative array questions |
Date: |
Thu, 19 Jul 2012 11:52:01 -0500 |
User-agent: |
KMail/4.8.3 (Linux/3.4.2-pf+; KDE/4.8.3; x86_64; ; ) |
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