I thought the -z
option in a bash test would be true if the condition evaluates to null and -n
would be true if the condition is not null. So then why is this happening?
var1=
echo ${#var1} # 0
[ -n $var1 ] && echo 'hi' # hi
unset var1
[ -n $var1 ] && echo 'hi' # still prints hi!
Aucun commentaire:
Enregistrer un commentaire