On Fri, 22 Oct 2010, Andreas Schwab wrote:
Axel <axel.aze...@laposte.net> writes:
After your answer, I checked and I think the error message is not
related to the variable name collision :
[a...@axel-asus plugins]$ unset foo
[a...@axel-asus plugins]$ func()
{
echo "[a]=5 [b]=10"
}
[a...@axel-asus plugins]$ declare -A foo=( $(func) )
$ declare -A foo=('[a]=5')
Drop the qotes:
declare -A foo=( [a]=5 )
bash: foo: [a]=5: must use subscript when assigning associative array
$ eval "declare -A foo=($(echo '[a]=5'))"; echo ${foo[a]}
5
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)