Afficher un message
Vieux 06/01/2008, 14h15   #8
Maxwell Lol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Comparing two strings (one may be a null)

Cyrus Kriticos <cyrus.kriticos@googlemail.com> writes:

> if [ "$foo" = "bar" ] ; then


Another approach is to use

if [ X$foo = Xbar ] ; then

That's in case $foo has the value of "=", which would case the line to
be evaluated as

if [ = = bar ]

which can generate a syntax error.
But if foo has a space, that fails as well.
Which leads to combining the two:

if [ "X$foo" = Xbar ] ; then

Cheers....
  Réponse avec citation
 
Page generated in 0,07085 seconds with 9 queries