0

SCRIPT :

IMAGE=$imgvalue;
if  [ $imgvalue :=1 ]
then
    echo DO=ABC;
elif [ $imgvalue :=2 ]
then
    echo DO=ETC;
elif [ $imgvalue :=3 ]
then
    echo DO=XYZ;
else
    echo "$imgvalue is unsupported";
    exit 1; 
fi

In the script above, IMAGE=1, IMAGE=2, IMAGE=3 whatever may be the value I have assigned. It's showing only DO=ABC. Other conditions not working. Can anyone explain what's wrong with my script?

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271

1 Answers1

0

If $imgvalue is not an empty string, your first test is a syntax error, so I am assuming it is empty in the tests you are doing. In that case, your first test is equivalent to:

if [ :=1 ]

which is always true because :=1 is not an empty string. You probably meant to write:

if [ "$imgvalue" = 1 ]
William Pursell
  • 204,365
  • 48
  • 270
  • 300