On Thu, Mar 14, 2019 at 05:30:00PM -0500, A. Wilcox wrote:
> Thus, the terms "undefined" and "unspecified"
> It is therefore conformant for a POSIX shell script to use any of the
> unspecified keywords, as long as they can "deal with" the unspecified
A shell script does not "deal" with the behaviour, unless it actually
> This can be trivially accomplished using `type` and defining a small
> `local` function for shells that don't have it, *if* abuild were ever
Then this has to be done, before being able to say that the script "deals"
with a statement possibly unknown to the shell interpreter.
> to *use* such a shell. Note that I doubt that would be possible anyway,
> as abuild require multiple changes that were rejected when we proposed
> strict POSIX compatibility. (This was so we could use zsh or dash as
> /bin/sh and let abuild use a /bin/sh hashbang instead of requiring a
> hard dependency on BusyBox. We gave up and gave it a hashbang of
> /bin/bash in our soft-fork.) In addition, all build scripts inside of
> packages which use /bin/sh as their hashbang would *also* have to be
> compatible with this theoretical shell.
This is a separate argument, saying that because other parties are
not disciplined enough, you choose not to bother. Of course, this
may be practically sound, but how big is your gain by choosing
to write non-portable code?
Other parties' questionable behaviour does not preclude one from writing
portable scripts. This actually does not cost too much overhead, but
makes the reuse of the code and of the trained coding skills (including
people who for any reason read your code) more reliable and portable,
I would say more efficient.
Received on Fri Mar 15 2019 - 16:04:36 UTC