bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handling of test == by BASH's POSIX mode


From: Jon Seymour
Subject: Re: handling of test == by BASH's POSIX mode
Date: Sun, 27 May 2012 23:09:03 +1000

On Sun, May 27, 2012 at 9:31 PM, Andreas Schwab <address@hidden> wrote:
> Jon Seymour <address@hidden> writes:
>
>> As it stands, I can't use bash's POSIX mode to verify the validity or
>> otherwise of a POSIX script because bash won't report these kinds of
>> errors - even when running in POSIX mode.
>
> You can't do that anyway: POSIX mode does not disable proper extensions
> to POSIX, only those that conflict with POSIX.  Specifically, in the
> case of the test utility, POSIX makes the behaviour unspecified when a
> three argument invocation does not match the POSIX-defined binary
> operators.

I understand that the behaviour is unspecitied by POSIX - I didn't
know that before, but I know that now - thanks.

That said, from the point of view of promoting interoperable scripts,
my view is that it (in an ideal world**) would be better if bash chose
to fail, while executing in POSIX mode, in this case.

Yes, it would be annoying to the script writer who has to replace ==
with =, but at least the script eco-system as a whole would benefit
from a more conservative understanding of what it means to be a valid
POSIX script. As it stands now, it is well nigh impossible to avoid
undefined behaviour when the interpreter chooses to gracefully glosses
over the fact that the script is utiising.

** I guess I can except that current bash behaviour is, on balance,
the correct pragmatic decision since there would no doubt be
widespread carnage in the scripting universe if bash was suddenly to
become pickier about how it supports POSIX mode. Is there a case, I
wonder, for enabling more conservative interpretation of test
operators via a shell option of some kind?

>
>> There is an --enable-strict-posix (?) configuration option. Will this do
>> what I expect?
>
> That just switches the default for POSIX mode.

Thanks.

jon.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]