Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Inconsistent behavior of the test command with associative arrays



% zsh -f
% typeset -A array=(key1 value1 key2 value2);
test $array[key1] ; echo $? ;
test $array[key2] ; echo $? ;
test $array[key3] ; echo $? ;
test $array[key4] ; echo $? ;
if test $array[key1] -a $array[key2] ; then
  echo "Condition evaluated to true" ;
fi                                             
if test $array[key3] -a $array[key4] ; then             
  echo "Condition evaluated to true" ;
fi
0
0
1
1
Condition evaluated to true
Condition evaluated to true


Messages sorted by: Reverse Date, Date, Thread, Author