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. Shell scripting would be nicer if the shell could be less crufty. For example, get rid of all the footguns about expanding unquoted variables...
> 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.
> 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.
>I think it's highly unfortunate it became the "de-facto 'modern' standard".
Perhaps you're right. Perhaps. However, the most important consequence of bash creation and dissemination is that there is a de-facto standard.
So until we don't have another de-facto standard hundreds of thousands of typical shell users are happy with bash. With all its issues, weaknesses and disadvantages...
I'm not so sure people are "happy" with bash, given the complaints that keep returning, and that many aren't aware that zsh is actually different in this regard.
I also think the value of being the de-facto standard is somewhat overrated (as is the value of portability by the way); many scripts only run on one platform, one you control. zsh is not hard to install.
> get rid of all the footguns about expanding unquoted variables
The shell's power & it's footguns are one in the same. "Fix" them, and becomes a general-purpose language--a jack of all trades & master of none. CS professors will love it, but doing anything meaningful in the shell will look more like a one-page python script instead of the l337 one-liners the Jersey boys graced us with.
I've seen so many "bash but with type inference, unit testing, and all those nice features to make your code safer."
I want to see someone try "bash but we really embrace the insanity."
For instance, make recursively affecting all files in subdirectories the default? Or have a global option where any prompt is automatically answered with yes? Maybe some heuristics to detect if the user wants unquoted variables expanded?