... which is why I try to write as much stuff as POSIX sh as possible, and sometimes I have to throw in a Bashism to get by.
And I say this as someone that wishes sh was better, semi-lovingly.
... which is why I try to write as much stuff as POSIX sh as possible, and sometimes I have to throw in a Bashism to get by.
And I say this as someone that wishes sh was better, semi-lovingly.
And that also feels like the problem with extending a script with a few bashisms too, as you're suddenly trying to remember when that feature appeared. Off the top of my head I'm wondering what things won't be available to Mac users because it ships with a pre-GPLv3 bash for example.
Side note: it's also one of (or the ?) most popular Haskell projects out there: https://github.com/koalaman/shellcheck/
Why do we need a one true shell that implements the standard? Am I misunderstanding you…? The whole point of a standard is that everyone implements it so the different implementations don’t matter (and everyone does implement it, in the case of POSIX shell, minus a couple things like [ -t ] and some bash defaults).
The situation - as I see it - is that we have a spec, and we have systems that ship a /bin/sh that implements something like it. If people are targetting their system's /bin/sh, then they're writing scripts for their /bin/sh implementation not posix compliant shells. For example, my install uses dash which has features beyond the posix spec which I have to eschew to produce portable scripts.
As a sibling comment points out shellcheck will point out a lot problems, but it requires people choosing to use it. You only have to dive around /usr/bin for a little while to see its usage isn't universal ;)
Of course, if the differences in implementation don't affect your usecase then it simply doesn't matter.
There will always be a place for the universal shells and text editors. Bash and vim aren't going away any time soon. But there are plenty of places for non-default choices. Vim's existence doesn't mean Sublime doesn't have a place.