Problem with ash -n non-zero length string test

Mike Frysinger vapier at gentoo.org
Sat Jul 7 14:58:20 PDT 2007


On Saturday 07 July 2007, Dallas Clement wrote:
> 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

you need to make sure you quote things as this will be fragile regardless of 
the shell

[ -n "$some_var" ]
[ -z "$some_var" ]
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: This is a digitally signed message part.
Url : http://busybox.net/lists/busybox/attachments/20070707/4d294252/attachment.pgp 


More information about the busybox mailing list