Re: gA: declare and assign vs. declare then assign
From:
Chet Ramey
Subject:
Re: gA: declare and assign vs. declare then assign
Date:
Thu, 16 Jan 2014 10:16:49 -0500
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
On 1/15/14, 10:04 PM, Carlos Pita wrote:
> Bash Version: 4.2
> Patch Level: 45
> Release Status: release
>
> Description:
>
> When declaring a global associative array inside a function and
> assigning a value to it at the same time, then the array is not
> globally visible. This doesn't happen if I declare the array first and
> then do the assignment. That is:
>
> Buggy?:
> function f {
> declare -gA a=([a]=2 [b]=4)
> }
This is a bug in bash-4.2 that is fixed in bash-4.3. It looks like it was
fixed back in November, 2012.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/