On Jan 2, 2023, at 9:51 AM, Larry McVoy
<lm(a)mcvoy.com> wrote:
On Mon, Jan 02, 2023 at 11:25:06AM -0500, Clem Cole wrote:
Like Larry, I have always been a meany and I have
tried to make darned sure
my folks (even to this day - we will see how long that last after I retire)
use V7 syntax scripts - not bash, not even korn.
And as we shipped
scripts that people expected to work, you can't fix their /bin/sh.
I won that argument over and over and eventually we all instinctively
wrote portable scripts.
I feel like after POSIX.2 had had a few years to settle, it was OK to use *that* as your
scripting language (I particularly like $() rather than backticks, because of nestability,
although you can certainly argue that if you're regularly nesting your
interpolations, it's the design that's broken, not the specific syntax of the
command).
At least as long as you put a very visible comment right at the top saying
"We're assuming POSIX shell."
But of course the "after it had had a few years to settle" is doing a lot of
lifting there. During the Unix Wars, yeah, clearly using v7 sh as
lowest-common-denominator was the right choice. After the establishment of Linux Hegemony
sometime in the early 2000s, I think I remember that you could pretty much count on
everyone at least providing a POSIX shell, even if it wasn't the default. (But of
course by then, "everyone" that wasn't Linux or OS X was already down to
more-or-less Sun, IBM, HP, and DEC/Compaq.)
These days, if you have a vendor-supplied shell script that DOESN'T work correctly
under a POSIX /bin/sh, that should be treated as a defect.
Adam