On Sun, May 27, 2012 at 9:31 PM, Andreas Schwab <sch...@linux-m68k.org> wrote: > Jon Seymour <jon.seym...@gmail.com> 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.