Frequently Asked Question
What is POSIX sh, and why does it matter?
POSIX is a family of standards (IEEE 1003) that codifies what a Unix-like system
must offer, from system calls up to shell behaviour. POSIX sh is the chapter that
specifies the shell language: which builtins must exist, how variables expand, how
quoting works, how if, for, and while are written. Any shell that conforms
can run any POSIX shell script.
Why it matters: portability. A script written in pure POSIX sh will run on Debian's
dash, on a busybox-based router, on macOS, on FreeBSD, and on any Linux system,
without surprises. Once you start using bash-specific features ("bashisms") like
[[ ... ]], arrays, <<<, or ${var,,}, the script will fail on dash and on any
minimal shell. System scripts on Debian and Ubuntu enforce this strictly, that's
why /bin/sh points to dash. For your own scripts the practical rule is: if you
start it with #!/bin/sh, stick to POSIX; if you want bash features, start it with
#!/bin/bash.