Understanding the Differences Between Shells
In addition to defining a specific shell that you want to use, such as /bin/bash or /bin/zsh, you can also define the generic /bin/sh shell to make your scripts more portable, as you see here:
#!/bin/sh
This generic sh shell allows you to run your scripts on different systems that might or might not have bash installed. But, here’s the problem. Years ago, sh used to always be the Bourne shell. Nowadays, sh is still the Bourne shell on some operating systems, but is something else entirely on other operating systems. Here’s the breakdown of how it works:
- On most BSD-type systems, such as FreeBSD and OpenBSD,
shis the old-school Bourne shell. According to theshman page, it only supports POSIX-compliant features, plus a few BSD extensions. - On Red Hat-type systems,
shis a symbolic link that points to thebashexecutable. - On Debian/Ubuntu-type systems,
shis a symbolic link that points to the...