[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [EXTERNAL] - Re: This errors in 4.4, did not in 4.2: set -u; declare
From: |
Greg Wooledge |
Subject: |
Re: [EXTERNAL] - Re: This errors in 4.4, did not in 4.2: set -u; declare -A foo; echo ${#foo[@]} |
Date: |
Fri, 8 Nov 2024 12:55:46 -0500 |
On Fri, Nov 08, 2024 at 15:33:29 +0000, David Linden wrote:
> FYI, since I'm reporting behavior of 4.2 and this appears fixed in 4.4.
>
> In 4.2, it seems that providing the =() as part of the declaration throws
> away the -g-ness of the declaration-within-a-function. I need to touch it
> after the declare:
>
> (10:29)condor:~[518,18]$ bash -c 'function foo() { declare -g -A bar;
> bar[baz]=quux; }; foo; echo ${#bar[@]}'
> 1
> (10:29)condor:~[519,19]$ bash -c 'function foo() { declare -g -A bar=();
> bar[baz]=quux; }; foo; echo ${#bar[@]}'
> 0
> (10:29)condor:~[520,20]$ bash -c 'function foo() { declare -g -A bar; bar=();
> bar[baz]=quux; }; foo; echo ${#bar[@]}'
> 1
It looks like this was fixed in 4.3. Since this isn't a "serious" bug
(like Shellshock serious), it's extremely improbable there will be any
patches released for such an old version of bash (bash 4.2 is from 2011).