|
|
|
|
|
by quotemstr
1695 days ago
|
|
> It's also worth reading through the POSIX manpages for POSIX sh if you want to be a good shell scripter. Or you can give the middle finger to POSIX, write shell scripts for bash, or even zsh, and end up with faster, more correct, and more beautiful shell scripts that in practice are just as portable as the ones that mindlessly follow the limited and bizarre POSIX shell spec. I'll write POSIXly-correct shell scripts when the POSIX people stop pretending it's still 1995. |
|
The POSIX shell is the Bourne shell (1979) plus half of the innovations brought by ksh88.
The other half of the improvements from ksh88 and all of the improvements from ksh93 are not included in the POSIX shell standard.
Also for POSIX compliant shells one must not forget that also the other programs invoked by the shell must not be used with non-POSIX options.
For example, in a bash script I used the ksh93 syntax:
Then I wanted to make it POSIX compliant and I rewrote it in the longer: But then I discovered that POSIX expr lacks substr, so I had to rewrite the expression into the even longer: which is the only POSIX compliant way to extract substrings.In most cases the rational way is to write scripts for bash or zsh, which include all the ksh93 features plus brace expansion (from csh, then enhanced by zsh).
Writing POSIX compliant scripts results in much longer scripts in which the chances of bugs are much higher.