bug-bash
[Top][All Lists]
Advanced

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

Re: associative arrays and [[ -v


From: Eduardo A . Bustamante López
Subject: Re: associative arrays and [[ -v
Date: Fri, 17 Apr 2015 07:54:35 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

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/



reply via email to

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