On Fri, Jan 17, 2025, at 9:19 PM, Christoph Anton Mitterer via austin-group-l
at The Open Group wrote:
> The problem with --posix modes or the likes is IMO that it doesn't
> typically help the developer with portable programming.
The problem with demanding that implementations break backward
compatibility by changing their default modes for your benefit
is that that does not benefit their existing users.
> If I write a script that should run under any shell, it would still be
> upon the user to actually call the used shell with whichever
> option/envvar/etc. is needed to get it into POSIX mode, which one
> cannot really count upon and in practice people will typically just use
> the "normal" mode.
When targeting POSIX, arguably the only shell available to you is
one called "sh", and you should tell your users to run your scripts
with "sh", and as long as their shells conform to POSIX when invoked
as "sh" -- which often means switching to a distinct POSIX mode --
then everything's kosher.
> Also, one cannot (as a script developer) really test for it, at least
> not portably.
Just enable it in shells that have it, using something like this:
(set -o posix) 2>/dev/null && set -o posix
--
vq