-v no longer works for associative arrays

2022-10-13 Thread Bryan Roessler
Configuration Information [Automatically generated, do not change]:

Machine: x86_64

OS: linux-musl

Compiler: gcc

Compilation CFLAGS: -g -O2

uname output: Linux d1a7b22c3308 5.19.14-200.fc36.x86_64 #1 SMP
PREEMPT_DYNAMIC Wed Oct
Machine Type: x86_64-pc-linux-musl



Bash Version: 5.2

Patch Level: 2

Release Status: release



Description:

bash-5.2# declare -A a
bash-5.2# a[foo]=bar
bash-5.2# [[ -v a[@] ]]; echo $?
1

bash-5.1# declare -A a
bash-5.1# a[foo]=bar
bash-5.1# [[ -v a[@] ]]; echo $?
0

If this is by design I missed it.


Repeat-By:

See above


Re: -v no longer works for associative arrays

2022-10-13 Thread Bryan Roessler
For indexed arrays, yes. I hadn't made the connection with associative
arrays since I don't typically index them with numbers, thanks.

$ declare -A f[0]=true
$ declare -A g[foo]=bar
$ test -v f; echo $?
0
$ test -v g; echo $?
1

On Thu, Oct 13, 2022 at 12:10 PM Chet Ramey  wrote:

> On 10/13/22 12:06 PM, Oğuz wrote:
>
> >   test -v seems broken anyway
> >
> > $ declare -A foo=(a 42)
> > $ declare -a bar=(42)
> > $ test -v foo; echo $?
> > 1
> > $ test -v bar; echo $?
> > 0
>
> You know that referencing an array variable without a subscript is
> equivalent to referencing element 0 (or "0").
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
>
>