From owner-freebsd-bugs@freebsd.org Mon Sep 19 04:35:16 2016 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 50330BD682A for ; Mon, 19 Sep 2016 04:35:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 267BFB3A for ; Mon, 19 Sep 2016 04:35:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u8J4ZFhL074553 for ; Mon, 19 Sep 2016 04:35:16 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 206295] sh(1)/test(1) bug (precedence) Date: Mon, 19 Sep 2016 04:35:16 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 9.3-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: nibbana@gmx.us X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2016 04:35:16 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D206295 --- Comment #2 from nibbana@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 su= b- 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. --=20 You are receiving this mail because: You are the assignee for the bug.=