The duality of /bin/sh

A few weeks ago, I ran a shell script on an Ubuntu server and it didn't work the same as on my Arch Linux laptop. The reason for its behavior surprised me.

At first glance, the script looked quite standard:

#!/bin/sh

# some commands here
# ...

After digging through the internet, I read this article on LWN about /bin/sh referring to /bin/dash on Ubuntu. And on Arch Linux, which is what I use on my laptop, /bin/sh refers to /bin/bash.

Unfortunately, bash and dash are not compatible.

From now on, I will explicitly define which shell I want my scripts to be executed with. I'll be using bash because it is my login shell and because it is recommended in the Google scripting guidelines:

#!/bin/bash

# some commands here
# ...
The duality of /bin/sh
Share this