Hacker News new | ask | show | jobs
by stouset 1361 days ago
If you want to write scripts to target bash, target bash with your shebang.

If your shebang is `/bin/sh`, then it's nice to have a strictly POSIX-compliant shell.

2 comments

Bash does not "turn off" all its extra functionality when called as /bin/sh, it just alters the behaviors that are clearly in conflict with (what was) POSIX.2.

Arrays are still available in POSIX mode, even though they do not comply.

Which is why I think it’s good that Debian has a POSIX-strict `/bin/sh`. I have no idea what bash’s flawed POSIX mode has to do with this.
Except if any program calls system(3) which always using /bin/sh. I maintain many core Linux packages and this Debian nonsense is a constant irritation with no discernible benefit.
If it doesn’t work with ‘this Debian nonsense’, you’re doing it wrong and you’re contributing to a bad faux dependency on bash as /bin/sh.

The Unix world is better off if there is the option of using another shell that isn’t bug for bug compatible with bash.

This behavior is what leads to systems that have to emulate ancient bloated interfaces because they need to support applications that use apis that are defined as ‘how that program does it’. That’s bad. We should avoid it. Avoiding it is a benefit.

One secondary reason for the dash choice is speed.

The dash shell has been reported to be four times faster than bash.

That definitely impacts boot time. POSIX compliance is not the only benefit.

system("/usr/bin/env bash -c '...'");