|
|
|
|
|
by susam
732 days ago
|
|
> Aren't people targetting bash or basic bourne shell features intead of posix? I know many banks still have AIX systems with shells like ksh89, ksh93, etc. as the default shell. So if a shell script is written to work with a POSIX shell (instead of a particular shell), it has a better chance of running on such systems. Also, on Debian, the default non-interactive shell is dash [1]. This is the Debian Almquist Shell (dash). It is a POSIX-compliant shell derived from ash. So again, if we write system scripts for Debian and want it to run on Debian without any hassle, it makes sense to write the system scripts to conform to POSIX shell. Although shellcheck cannot perform full POSIX compliance check at this time, it is still a pretty good tool that can help with checking compliance with dash in particular. [1]: https://packages.debian.org/stable/dash |
|
Or explicitly use bash in your shebang.
One of the problems with Bash is that it insists on doing bash-y things even when you tell it to act like sh.
People ask why you should write (or at least test) code to be multi-platform (even the basics of running it on BSD or macOS): it's because it forces you to be honest. Things change and initial assumptions may not be the same forever.
* https://wiki.debian.org/Shell
* https://archlinux.org/packages/?name=checkbashisms
* https://wiki.ubuntu.com/DashAsBinSh