Monday, November 15, 2010

/bin/sh is not /bin/bash on Solaris

I was trying to execute a script, which was generally meant to run on a Linux box. On executing the script I got the following error


bash-3.00# /test.sh
+ [ -e /etc/inittab ]
/test.sh: test: argument expected


The contents of test.sh is


bash-3.00# cat /test.sh
#!/bin/sh
set -x on
if [ -e /etc/inittab ]; then
echo true
fi

when I change the line #!/bin/sh to #!/bin/bash, the script execution works. Turns out that /bin/sh and /bin/bash aren't the same on Solaris and you need to ensure this change.

Labels: , ,