vendredi 20 octobre 2017

Shell 'if statement' comparison [duplicate]

This question already has an answer here:

Today I saw the following comparison in an IBM shell script:

if [ "X$DEBUG" != "X" ]
then
    # do stuff here
fi

What's the purpose of the X in the if statement?

Why not simply compare it as:

if [ "$DEBUG" != "" ]

Or:

if [ -z "$DEBUG" ]

Aucun commentaire:

Enregistrer un commentaire