Re: What shells fail to work if comparing with "" ?

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

 



On 02/10/2011 12:40 PM, Ralf Wildenhues wrote:
> Hello David,
> 
> * Dr. David Kirkby wrote on Thu, Feb 10, 2011 at 07:56:24PM CET:
>> 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?
> 
> It's not shells that break.  It's these kinds of issues:
> http://thread.gmane.org/gmane.comp.sysutils.autoconf.general/13706

Ralf pointed out a completely different point from the Solaris /bin/sh
syntax issue - that is, that in autoconf scripts, [ and ] are special to
m4, and require extra effort to use, so you are more portable using:

test "x$STR" = x

than you are using:

[ "x$STR" = x ]

so that m4 doesn't eat the [ and ].

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux