Drew DeVault writes about the POSIX shell:
What the heck is the POSIX shell anyway? Well, the POSIX (the Portable Operating System Interface) shell is the standard Unix shell - standard meaning it was formally defined and shipped in a published standard. This makes shell scripts written for it portable, something no other shell can lay claim to. The POSIX shell is basically a formalized version of the venerable Bourne shell, and on your system it lives at
/bin/sh, unless you’re one of the unlucky masses for whom this is a symlink to bash.
If you’re on macOS then unfortunately you’re part of those “unwashed messes” that symlink1
bash. This has some interesting implications, in that even if you use the
#!/bin/sh shebang in your scripts, they won’t be guaranteed to be portable to other (Unix and Linux) systems. I’ve found a practical solution is to just use the
#!/usr/bin/env bash, which will make your scripts portable to any other system running