I was checking to see if an associative array had a member:


echo $BASH_VERSION
4.4.5(1)-release
 declare -A requires=([squid]="-d /var/cache/squid/run")

This works as expected:

 if [[ ${requires[xxx]:-} ]]; then echo ok; else echo not; fi
not

But this didn't (misspelling of hash name):

 if [[ ${requirs[xxx]:-} ]]; then echo ok; else echo not; fi
bash: xxx: unbound variable

Shouldn't it have said:

bash: requirs: unbound variable?




Reply via email to