Problem with ash -n non-zero length string test
Dallas Clement
dallas.a.clement at gmail.com
Sat Jul 7 21:34:35 UTC 2007
Hello All,
I'm experiencing some weird things when trying to use -n to test for a
non-empty string as in the following example.
boot_drive_name=""
if [ -n $boot_drive_name ]; then
retval=0
else
echo "Could not determine boot drive name."
fi
To my surprise, this condition evaluates true and I do not see my echo
message.
However, if I use the -z test, with the following logic, I do see my
echo message.
boot_drive_name=""
if [ -z $boot_drive_name ]; then
echo "Could not determine boot drive name."
else
retval=0
fi
I'm not sure if -n does not work 100 percent of the time in all cases or
if it is an erratic problem that only happens under certain conditions.
I have seen it fail in several different logic scenarios.
Has anyone else observed this? Am I doing something wrong?
I'm seeing this on busybox 1.6.0
More information about the busybox
mailing list