bug-bash
[Top][All Lists]
Advanced

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

Re: associative arrays and [[ -v


From: isabella parakiss
Subject: Re: associative arrays and [[ -v
Date: Fri, 17 Apr 2015 15:10:27 +0200

On 4/17/15, Eduardo A. Bustamante López <dualbus@gmail.com> wrote:
> On Fri, Apr 17, 2015 at 11:12:50AM +0200, isabella parakiss wrote:
>> I need to check if an element in an associative array is set.  What's the
>> correct way to test it?
>
> dualbus@yaqui ~ % export key; for key in \* x y; do bash -c 'declare -A
> a=([x]=y [y]=); echo "$key" ${a[$key]+inarray}; declare -p a'; done
> *
> declare -A a='([x]="y" [y]="" )'
> x inarray
> declare -A a='([x]="y" [y]="" )'
> y inarray
> declare -A a='([x]="y" [y]="" )'
>
> --
> Eduardo Bustamante
> https://dualbus.me/
>

Ok that kind of makes test -v useless, doesn't it?



reply via email to

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