jeudi 27 août 2015

eval as if statement condition

Why is the output of the following statement true?

VAR="[[ "x"=="y" ]]"
if eval $VAR ; then
    echo "true"
else
    echo "false"
fi

Is there any other way to use a variable as condition for an if statement in bash?

Aucun commentaire:

Enregistrer un commentaire