[prog] bash: string comparisons in conditionals

Daniel lc-programming at nada.refused.cc
Thu Apr 22 21:13:16 EST 2004

Hi Riccarda,

On Thu, Apr 22, 2004 at 09:27:21AM +0200, Riccarda Cassini wrote:
> Daniel <lc-programming at nada.refused.cc> wrote:
> > Afair, the strings are prefixed with "x", to be compatible with older
> > (very old) versions of the test programm, which used to fail with
> > [ "" = "" ].
> Has this bug (or feature) still any practical relevance nowadays?
> (with nowadys I mean anything stretching back for, let's say, 5 years
> or so)

Well, i've googled a bit and I have to tell, that I was wrong. :)
I've found a thread where my opinion is also present, but it was

      test x"$var" != "x" && echo '$var' is not empty

The point is, that the "x" turns the first argument into an ordinary
word, even when "$var" starts with "-". Read the full thread



More information about the Programming mailing list