[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 20:45:46 +1000 |
On 27/05/2012, at 17:39, Geir Hauge <geir.hauge@gmail.com> wrote:
> 2012/5/27 Jon Seymour <jon.seymour@gmail.com>:
>> Is there a reason why bash doesn't treat == as an illegal test
>> operator when running in POSIX mode?
>
> POSIX does not say == is not allowed.
>
> POSIX tells you what the shell should at least be able to do. A POSIX
> compliant shell can have whatever other features it likes, as long as
> the POSIX features are covered.
>
I guess the question is better phrased thus: what use case is usefully served
by having bash's POSIX mode support a superset of test operators than other
compliant POSIX shells? 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.
There is an --enable-strict-posix (?) configuration option. Will this do what I
expect?
>
>> This is problematic because use of test == in scripts that should be
>> POSIX isn't getting caught when I run them under bash's POSIX mode.
>> The scripts then fail when run under dash which seems to be stricter
>> about this.
>
> Don't use non-POSIX features in a POSIX script, and you'll be fine.
> http://www.opengroup.org/onlinepubs/9699919799/utilities/contents.html
>
Which is the exactly the point. Practically speaking when I write scripts I
expect an interpreter that claims to be running in POSIX mode to give me some
help to flag usage of non POSIX idioms. Yes, I can second guess the interpreter
by reading the spec, but is this really the most efficient way to catch these
kinds of errors?
Jon.
- handling of test == by BASH's POSIX mode, Jon Seymour, 2012/05/27
- Re: handling of test == by BASH's POSIX mode, Geir Hauge, 2012/05/27
- Re: handling of test == by BASH's POSIX mode,
Jon Seymour <=
- Re: handling of test == by BASH's POSIX mode, Andreas Schwab, 2012/05/27
- Re: handling of test == by BASH's POSIX mode, Jon Seymour, 2012/05/27
- Re: handling of test == by BASH's POSIX mode, Jon Seymour, 2012/05/27
- Re: handling of test == by BASH's POSIX mode, Dan Douglas, 2012/05/27
- Re: handling of test == by BASH's POSIX mode, Jon Seymour, 2012/05/27
- Re: handling of test == by BASH's POSIX mode, Eric Blake, 2012/05/28
- Re: handling of test == by BASH's POSIX mode, Jon Seymour, 2012/05/28
Re: handling of test == by BASH's POSIX mode, Eric Blake, 2012/05/28