Linux – What causes = and == to be interpreted differently in shell scripts?

What causes = and == to be interpreted differently in shell scripts?… here is a solution to the problem.

What causes = and == to be interpreted differently in shell scripts?

I recently updated to Ubuntu 13.04 and one of my shell scripts crashed as a result:

#!/bin/sh    
...
if [ "$SHOW_USAGE" == "true" ]; then

./install.sh: 248: [: false: unexpected operator

Now, I know I can fix this by replacing the double equal sign (“==”) with an equal sign (“=”), but what is causing the Ubuntu behavior difference between 13.04 and previous Ubuntu versions? Is there a way to revert to a more flexible interpretation of the previous version?

Solution

/

bin/sh (not /bin.sh as you wrote in your post) used to link to /bin/bash, but now links to /bin/dash on Ubuntu. Bash tolerates some bashism, even if it is called sh.

Related Problems and Solutions