[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange re-initialization of array. Bug or feature?
From: |
Chet Ramey |
Subject: |
Re: Strange re-initialization of array. Bug or feature? |
Date: |
Fri, 30 Nov 2012 19:43:47 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 |
On 11/27/12 7:37 PM, Tim Friske wrote:
> If sourced at least twice from another script I get the following output
> printed:
>
> AAA
> BBB
> declare -A ONCE='()'
> CCC
> declare -A ONCE='([std.bash]="1" )'
> BBB
> declare -Ai ONCE='()'
> CCC
> declare -Ai ONCE='([std.bash]="1" )'
>
> If I remove the initialization "=()" from "declare -gAi ONCE" I get the
> following output printed:
>
> AAA
> BBB
> declare -Ai ONCE='()'
> CCC
> declare -Ai ONCE='([std.bash]="1" )'
> BBB
> declare -Ai ONCE='([std.bash]="1" )'
>
> The "declare -gAi ONCE=()" seems to get executed every time although
> surrounded by "[[ ! -v ONCE ]]" whereas "echo AAA" within the same if-block
> only the first time.
>
> Is this a bug or feature?
This is the same bug I described earlier today, with the same fix.
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/