Sometimes when you run a bash/shell command and you get errors, it might be that your shell is using dash.
We have a script to check and install npm modules:
if [[ ${NPM_INSTALL} == 'YES' ]]
then
echo "$(tput setaf 4)Doing NPM Install...$(tput sgr0)"
fi
then when we run the script we get
sh test.sh -npm
test.sh: 12: test.sh: [[: not found
To see what shell your server is using run the following
$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 ago 15 2012 /bin/sh > dash
As you can see, /bin/sh is a link to "dash" (not bash), and [[
is bash syntactic sugarness. So I just replaced the link to /bin/bash. Careful using rm like this in your system!
All you need to do is remove the symbolic link to dash and replace it with bash/sh
$ sudo rm /bin/sh
$ sudo ln -s /bin/bash /bin/sh
Now when i run the command it goes into the if statement
sh test.sh --npm
Doing NPM Install...