4 ms·
> Sometimes I pause to think how we're held back by needing to make our shell scripts backwards compatible with Bash or POSIX, because that's what is installed
by arinlen 4y ago
> Sometimes I pause to think how we're held back by needing to make our shell scripts backwards compatible with Bash or POSIX, because that's what is installed by default.
I think you're missing the forest for the trees.
Bash is installed by default because Bash is specified in an international standard dubbed the Portable Operating System Interface (POSIX). Your bash scripts are not backwards compatible. Your bash scripts are compatible, and portable, and standardized, because that's their point, and the whole point of POSIX.
No one is held back by bash or POSIX. You are free to use anything that suits your fancy. Feel free to whip out scripts in Python or Perl or Ruby. Some people do, and last time I checked some operating systems like macOS shipped their interpreters by default. Odds are you are free to easily install those interpreters in those who don't.
- theonemind 4y agoPOSIX most definitely does not specify bash. People typically use the word "bashism" for POSIX-shell-incompatible bash behavior used in shell scripts. random high result from googling "bashism": https://betterprogramming.pub/24-bashism-to-avoid-for-posix-compliant-shell-scripts-8e7c09e0f49a https://betterprogramming.pub/24-bashism-to-avoid-for-posix-...
- Beltalowda 4y ago> No one is held back by bash or POSIX. You are free to use anything that suits your fancy. Feel free to whip out scripts in Python or Perl or Ruby. The point is that there are many improvements that could be made to bash which would retain the good properties but would get rid of the worst footguns and suckiness. Quite a number of these (though not all) have been available for decades in the form of zsh. Also, as pointed out already in another comment, bash is not in POSIX at all. POSIX is very much a "lowest common denominator"-kind of specification which moves at geological speeds. Even dash and busybox sh implement some non-POSIX features.