What shells fail to work if comparing with ?

2011-02-10 Thread Dr. David Kirkby
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,

Re: What shells fail to work if comparing with ?

2011-02-10 Thread Eric Blake
On 02/10/2011 11:56 AM, Dr. David Kirkby wrote: 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? At least Solaris /bin/sh mishandles particular $STR: $

Re: What shells fail to work if comparing with ?

2011-02-10 Thread Ralf Wildenhues
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.

Re: What shells fail to work if comparing with ?

2011-02-10 Thread Stefano Lattarini
On Thursday 10 February 2011, Dr David wrote: 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? Solaris 10 /bin/sh breaks with [ $var != ] for some (very

Re: What shells fail to work if comparing with ?

2011-02-10 Thread David Kirkby
On 10 February 2011 18:56, Dr. David Kirkby david.kir...@onetel.net wrote: 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

Re: What shells fail to work if comparing with ?

2011-02-10 Thread Eric Blake
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

Re: What shells fail to work if comparing with ?

2011-02-10 Thread Bob Friesenhahn
On Thu, 10 Feb 2011, Stefano Lattarini wrote: 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, Solaris 10 /bin/sh is not really old. I do see the issues you mention