bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: associative array assignment from the output of a function


From: Andreas Schwab
Subject: Re: associative array assignment from the output of a function
Date: Fri, 22 Oct 2010 17:09:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Axel <axel.azerty@laposte.net> writes:

> After your answer, I checked and I think the error message is not
> related to the variable name collision :
>
> [axel@axel-asus plugins]$ unset foo
> [axel@axel-asus plugins]$ func()
>> {
>> echo "[a]=5 [b]=10"
>> }
> [axel@axel-asus plugins]$ declare -A foo=( $(func) )

$ 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

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]