autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What shells fail to work if comparing with "" ?


From: Dr. David Kirkby
Subject: What shells fail to work if comparing with "" ?
Date: Thu, 10 Feb 2011 18:56:24 +0000
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.1.7) Gecko/20100214 Thunderbird/3.0.1

I know its considered bad practice to check for an empty string with something 
like:

if [ "$STR" = "" ] ; then

but what shells do actually break with this, and under what conditions?


I was proposing someone change a test like that to

if [ "x$STR" =  ] ; then

but someone has argued against this, saying he knows of no shell where the former is not acceptable. I realise this issue is probably more of a problem with older shells, but can anyone give me any examples of where the former will break, but the latter will be ok?



--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Dave




reply via email to

[Prev in Thread] Current Thread [Next in Thread]