[Bug 206295] sh(1)/test(1) bug (precedence)

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Jan 22 14:11:30 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206295

Jilles Tjoelker <jilles at FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jilles at FreeBSD.org

--- Comment #1 from Jilles Tjoelker <jilles at FreeBSD.org> ---
(In reply to nibbana from comment #0)
This may not make much sense, but per a literal reading of the 'test' page in
POSIX.1-2008 XCU, the -a or -o indeed binds more strongly than the !. This is
because -a and -o are explicitly said to be "binary primaries" and therefore ''
-a '' matches the first case of 3 arguments and ! '' -a '' matches the first
case of 4 arguments.

In bash, dash, zsh and yash, [ ! "" -a "" ] likewise returns true.

I recommend writing [ ! "" ] && [ "" ] or [ -z "" ] && [ -n "" ] instead.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list