[Bug 206295] sh(1)/test(1) bug (precedence)
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Mon Sep 19 04:35:16 UTC 2016
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206295
--- Comment #2 from nibbana at gmx.us ---
>From the test(1) manpage:
! expression True if expression is false.
NOTE: it is stating that (based on the use of the term 'expression',
that ! should have higher precedence than -a/-o ... there is no
indication that one should beware of any -a/-o operators that follow.
Also, this bizzare behavior only applies to the -a operator, not -o,
so that makes the current implementation doubly strange, and it only
applies to a 1st and not in further instances, eg:
"! expression -a expression -o ! expression -a expression"
$ [ ! "" -a "" ] && echo pass || echo fail
pass
$ [ ! "" -a "" -o ! "" -a "" ] && echo pass || echo fail
fail
expression1 -a expression2
True if both expression1 and expression2 are true.
expression1 -o expression2
True if either expression1 or expression2 are true.
( expression )
True if expression is true.
The -a operator has higher precedence than the -o operator.
GRAMMAR AMBIGUITY
The test grammar is inherently ambiguous. In order to assure a degree of
consistency, the cases described in the IEEE Std 1003.2 (``POSIX.2''),
section D11.2/4.62.4, standard are evaluated consistently according to
the rules specified in the standards document. All other cases are sub-
ject to the ambiguity in the command semantics.
NOTE: unfortunately, these documents are not easily accessible, and users
are, in a practical sense, forced to rely on the manpages.
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list