On Sat, Sep 17, 2011 at 09:11:16AM -0700, Regid Ichira wrote: > Within a shell, what is the difference between [ -n undefinedString ] and [ > -n "$undefinedString" ] ? > With bash I get: > > $ unset undefinedString > $ [ -n undefinedString ] && printf "$undefinedString" | od -c > 0000000 > $ [ -n "$undefinedString" ] && printf "$undefinedString" | od -c > $ [ -z "$undefinedString" ] && printf "$undefinedString" | od -c > 0000000 > > > I mean, shouldn't [ -n undefinedString ], which I guess is without shell > expansion, give an error? Clearly > it is an empty string.
Actually, "undefinedString" *is* a string. However, "$undefinedString" is a variable that doesn't reference anything, so the above is behaving correctly. (Assuming you're using bash, which I probably shouldn't.) I would highly recommend lurking in comp.unix.shell, and searching the archives in GoogleGroups. It also wouldn't be a bad idea to bookmark the following pages: Bash Guide for Beginners http://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Advanced Bash Scripting Guide http://tldp.org/LDP/abs/html/ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20110917170925.ga2...@cerulean.myhome.westell.com