mercredi 19 juillet 2017

Bash judgement gets the unexpected result

This is the code of the my shell script:

#! /bin/bash

if ["$SHELL" = "/bin/bash"];then
        echo "this is bash"
elif ["$SHELL" = "aa"];then
        echo "this is aa"
else
        echo "this is not /bin/bash, but $SHELL"
fi

why I execute the test_bash_03 script file gets the else result? shouldn't it be:this is bash

aircraftdeMacBook-Pro:bash_demo ldl$ ./test_bash_03
./test_bash_03: line 3: [/bin/bash: No such file or directory
./test_bash_03: line 5: [/bin/bash: No such file or directory
this is not /bin/bash, but /bin/bash

And I echo the $SHELL I also get the /bin/bash

aircraftdeMacBook-Pro:bash_demo ldl$ echo $SHELL
/bin/bash

Aucun commentaire:

Enregistrer un commentaire