Hello,
when writing a shell script I experienced behaviour of test(1), which I really cannot explain.
-z is supposed to be True if the length of string is zero.
-n is supposed to be True if the length of string is nonzero.
Here is a script that shows the behaviour:
The output is to my surprise:
Did I miss something or is this a bug?
when writing a shell script I experienced behaviour of test(1), which I really cannot explain.
-z is supposed to be True if the length of string is zero.
-n is supposed to be True if the length of string is nonzero.
Here is a script that shows the behaviour:
Code:
#!/bin/sh
foo=
if [ -z $foo ] ; then
echo "A"
fi
if [ -n $foo ] ; then
echo "B"
fi
The output is to my surprise:
Code:
A
B
Did I miss something or is this a bug?