I know i can test a string whether it is empty with -z and test a string whether it is non empty with -n. So I write a script in ubuntu 10.10:
#!/bin/bash
A=
test -z $A && echo "A is empty"
test -n $A && echo "A is non empty"
test $A && echo "A is non empty"
str=""
test -z $str && echo "str is empty"
test -n $str && echo "str is non empty"
test $str && echo "str is non empty"
To my surprise, it output :
A is empty
A is non empty
str is empty
str is non empty
which I thing it should be
A is empty
str is empty
Could any Linux expert explain why ?
Thank you.