Tuesday, April 02, 2024

Re: Bash instead of ksh

On 24/04/03 12:25AM, jslee wrote:
> Thirdly, I recommend avoiding using /bin/sh in the #! line if you intend
> things to be portable because:
>
> * on Linux it might be bash or dash or busybox, depending on distribution
> * on macOS it might be bash or zsh or dash, depending on the state of a symlink, macOS version, the phase of the moon, and other factors (see: man 1 sh)
> * on OpenBSD it is pdksh in sh compatibility mode (set -o sh)

I disagree, /bin/sh (and sticking to features of the POSIX shell[1]) should be
the ideal, especially when portability is the goal.

That said, one of my disappointments with OpenBSD is that /etc/rc assumes ksh
while not having the /bin/ksh shebang as indication (so I can't use lksh in
place of /bin/sh). However, when put into perspective, it makes sense
considering security and control over updating the core parts of the system.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/sh.html

No comments:

Post a Comment