2 ms·
Bash developed before POSIX.2, so the old behavior of bash that is incompatible is suppressed when it runs as #!/bin/sh or when POSIX mode is otherwise set. My
by chasil 2y ago
Bash developed before POSIX.2, so the old behavior of bash that is incompatible is suppressed when it runs as #!/bin/sh or when POSIX mode is otherwise set.
My particular bugbear is "alias p=printf" which works in scripts when bash is /bin/sh but fails when it is /bin/bash.
This is because bash historically did not honor alias in scripts. The solution is to set POSIX mode.
So, you see, there are two bash shells, and you likely do not know know the pre-POSIX shell as well as you might think.
Just writing for POSIX.2 is more straightforward.