All this is in quotation marks. I donβt remember where, but someone explained this recently in SO or USE. Without quotes, it does not actually perform an empty / non-empty string test, but simply checks that -n or -z are not empty strings themselves. This is the same test that makes this possible:
$ var=-n $ if [ "$var" ] then echo whut fi
Returns whut .
This means that you can also have some kind of functional programming:
$ custom_test() { if [ "$1" "$2" ] then echo true else echo false fi } $ custom_test -z "$USER" false $ custom_test -n "$USER" true
source share