From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 05 10:55:29 2016 Received: (at submit) by debbugs.gnu.org; 5 Apr 2016 14:55:29 +0000 Received: from localhost ([127.0.0.1]:52444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anSO9-0004DF-Et for submit@debbugs.gnu.org; Tue, 05 Apr 2016 10:55:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52362) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anPc7-0008B8-Fw for submit@debbugs.gnu.org; Tue, 05 Apr 2016 07:57:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anPc1-0003ET-MC for submit@debbugs.gnu.org; Tue, 05 Apr 2016 07:57:38 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:59342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anPc1-0003EO-J9 for submit@debbugs.gnu.org; Tue, 05 Apr 2016 07:57:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anPc0-0005pP-MS for bug-coreutils@gnu.org; Tue, 05 Apr 2016 07:57:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anPbv-000399-Mo for bug-coreutils@gnu.org; Tue, 05 Apr 2016 07:57:36 -0400 Received: from smtp-3.sys.kth.se ([130.237.48.192]:37334) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anPbv-00037o-FV for bug-coreutils@gnu.org; Tue, 05 Apr 2016 07:57:31 -0400 Received: from smtp-3.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-3.sys.kth.se (Postfix) with ESMTP id 1BF7BE1F for ; Tue, 5 Apr 2016 13:57:29 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-3.sys.kth.se ([127.0.0.1]) by smtp-3.sys.kth.se (smtp-3.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id R5g-13wVPvrC for ; Tue, 5 Apr 2016 13:57:28 +0200 (CEST) X-KTH-Auth: maandree [81.228.219.220] X-KTH-mail-from: maandree@member.fsf.org X-KTH-rcpt-to: bug-coreutils@gnu.org Received: from localhost.localdomain (h220n13-jak-a12.ias.bredband.telia.com [81.228.219.220]) by smtp-3.sys.kth.se (Postfix) with ESMTPSA id 6DC3144E for ; Tue, 5 Apr 2016 13:57:25 +0200 (CEST) Date: Tue, 5 Apr 2016 13:57:16 +0200 From: Mattias =?UTF-8?B?QW5kcsOpZQ==?= To: bug-coreutils@gnu.org Subject: test: incorrect operator-precedence Message-ID: <20160405135716.0cce3e8c.maandree@kth.se> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-unknown-linux-gnu) X-Awesomeness: 120 % User-Agent: Claws Mail X-Operating-System: GNU/Linux MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/8xAYzIslHX2Dh5=8pOJ7uR8"; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 05 Apr 2016 10:55:28 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --Sig_/8xAYzIslHX2Dh5=8pOJ7uR8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Failing test-case #1: ./test -n -a -n fails and outputs ./test: extra argument =E2=80=98-n=E2=80=99 Expected behaviour is silent success, as seen in Bash's implementation. Explanation: -a has higher precedence than -n. Therefore the test is equivalent to ./test -n && ./test -n. ./test -n shall succeed because it is not an operator, but rather a non-empty string. Failing test-case #2: ./test ! '' -a '' shall fail (exit value 1), but in this implementation it succeeds. Explanation: ! has higher precedence than -a, therefore the test shall be equivalent to ./test ! '' && ./test '', not ! ./test '' -a ''. --Sig_/8xAYzIslHX2Dh5=8pOJ7uR8 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXA6gcAAoJEM4wYJDpiwjHqhwP/2Dp7NpUNm0pW2DPSl8E18ml z41Ik8rD5MxL8Ruym+i/C3nhgcaBGch42MQE95dkIH1LOI/whjAOUtHgm2YTVKeX xD4R4OObHMxvCK1f9h//98WlP+VPuXVQivSU4uaJsCElHVhJ+1c9p1Oddpm+VmPX 1IdyKOKiX+cUnb7i+4iyaqeM2i45PYm+3saRrce1hhhzsdktA1dOpFFaU6YtAtNW Ga4qMyPpa3C9MFMtoqAbdMhoaj1m5HuxySIzB+zmclTw7HFQ4dTcKduNN+vunByu EjhiqY6DAZFrfDBZ9ghjwa2GLyL/x/bsKEcdk56hAdZNwmbS8TOAV9hF36DmfFRr xe3/j4f79n3csx3njYWkFpfCiA1iz13XtijDzM2c0Xt8YetYZdn5hb1SrF5rb+C1 UFF9ZBb00cRzpqRcoPr3dCK7NwKSqx3Bn2/L6RGvsUS/JK60MCcHVzN0qWNBh/eI rmZHHFbVWcGkPv+1IYB2Q1SCGiq706uHuayi8iI2vbMaGAFXT9gxM5OvaeMFOkCp HLCWGoH0YX5s6aoIbNe/Nc43nvYVYgRK4EzV6H/nnGuZGC23qz8YvoEkTDTQYKq8 /D6OSNgMk1z+9zje289HXQJVbhV6WmTQsiufeY+IWfLPxrwanDeeu/vrOrRatD6w RM6jowiZZJOQcDaDgXFm =Ia+U -----END PGP SIGNATURE----- --Sig_/8xAYzIslHX2Dh5=8pOJ7uR8-- From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 05 11:09:51 2016 Received: (at 23222) by debbugs.gnu.org; 5 Apr 2016 15:09:51 +0000 Received: from localhost ([127.0.0.1]:52460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anSbz-0004ZN-P4 for submit@debbugs.gnu.org; Tue, 05 Apr 2016 11:09:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35814) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anSbu-0004Z8-Te; Tue, 05 Apr 2016 11:09:46 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 29B657AE83; Tue, 5 Apr 2016 15:09:42 +0000 (UTC) Received: from [10.3.113.124] (ovpn-113-124.phx2.redhat.com [10.3.113.124]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u35F9fS1000411; Tue, 5 Apr 2016 11:09:41 -0400 Subject: Re: bug#23222: test: incorrect operator-precedence To: =?UTF-8?Q?Mattias_Andr=c3=a9e?= , 23222@debbugs.gnu.org References: <20160405135716.0cce3e8c.maandree@kth.se> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <5703D534.7050505@redhat.com> Date: Tue, 5 Apr 2016 09:09:40 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <20160405135716.0cce3e8c.maandree@kth.se> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rB4VKwM52Axnk7KPwMHnvH0O4IrJv2XXp" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: 23222 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rB4VKwM52Axnk7KPwMHnvH0O4IrJv2XXp Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tag 23222 confirmed thanks On 04/05/2016 05:57 AM, Mattias Andr=C3=A9e wrote: > Failing test-case #1: >=20 > ./test -n -a -n >=20 > fails and outputs >=20 > ./test: extra argument =E2=80=98-n=E2=80=99 >=20 > Expected behaviour is silent success, as seen in > Bash's implementation. Thanks for the report. POSIX indeed says that -a is a binary primary, and also says that "3 arguments: If $2 is a binary primary, perform the binary test of $1 and $3."= (http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html) So by that reading, coreutils MUST parse your expression as: test \( -n \) -a \( -n \) whereas it appears that coreutils has instead accidentally parsed it as: test \( -n -a \) -n Not everyday someone finds a real bug in 'test'! That said, POSIX _also_ says that portable scripts MUST NOT use -a or -o; it is inherently ambiguous. You are better off fixing your script to use: test -n && test -n whether or not someone is able to quickly patch coreutils' bug. >=20 > Explanation: -a has higher precedence than -n. Not quite true. The POSIX rules state that -a is optional (non-XSI systems don't even have to have it), and that precedence has no bearing (rather, it is whether you have exactly three arguments that determines whether -a must be used in its role as a binary operator). >=20 > Failing test-case #2: >=20 > ./test ! '' -a '' >=20 > shall fail (exit value 1), but in this > implementation it succeeds. Sorry, but here, you're wrong. POSIX states: "4 arguments: If $1 is '!', negate the three-argument test of $2, $3, and $4." which means this parses as: test ! \( '' -a '' \) or as: test ! \( \( '' \) -a \( '' \) \) The negation of 'false and false' is true, so the exit status is correctly 0. >=20 > Explanation: ! has higher precedence than -a, Wrong. As mentioned above, the rules are based not on precedence, but on how many operands are present. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --rB4VKwM52Axnk7KPwMHnvH0O4IrJv2XXp Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXA9U1AAoJEKeha0olJ0NqoEsIAI31WcsiPwpLlWLBO4Bz6oJx HaumUDdRlEawUndXKJDESh3zd3vMcbc+5sul+MXgCnU4HlG7QZFzI2Wst4A2qX4X SvO+JJCM/eHESI1njfw08rM6gSCGIHwgea8O6Q0W5b8n0RXpJPQMkb1Sy81K+JQ5 RdYjL/ui4F+sIVUF2p/Txfj8/sEXdH5ioaG94hsUu+jW/mCAKOtIaB8kzBKV0puz pJCNTIyjrmz2vNddQsVO69J9ajg0O7EbfQ8uMuGdSCzQ01Dgh6CrABV1k21d+jFi L49ZmQh4E1frd9ZoL+YGA/kzZQOQ3tpKpjdXJMh3PfUhznn2hA/nixC+dfUXfQY= =Wfnu -----END PGP SIGNATURE----- --rB4VKwM52Axnk7KPwMHnvH0O4IrJv2XXp-- From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 05 14:38:28 2016 Received: (at 23222) by debbugs.gnu.org; 5 Apr 2016 18:38:28 +0000 Received: from localhost ([127.0.0.1]:50641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anVrv-0006kr-GW for submit@debbugs.gnu.org; Tue, 05 Apr 2016 14:38:27 -0400 Received: from smtp-3.sys.kth.se ([130.237.48.192]:50067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anVpz-0006hr-2w for 23222@debbugs.gnu.org; Tue, 05 Apr 2016 14:36:28 -0400 Received: from smtp-3.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-3.sys.kth.se (Postfix) with ESMTP id C0FF226C7; Tue, 5 Apr 2016 20:36:25 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-3.sys.kth.se ([127.0.0.1]) by smtp-3.sys.kth.se (smtp-3.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id yaMMJ180XqvX; Tue, 5 Apr 2016 20:36:24 +0200 (CEST) X-KTH-Auth: maandree [81.228.219.220] DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kth.se; s=default; t=1459881384; bh=PalG7ZRiJvHL+zkhgI6zEVAEipcUaMZwwzLk3dYl8uE=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=k5hg0NPSUq0Zp4iZa8BxXQMWcsv1h1jAkJiz0DAGf/i44aKuCo6gZqjNp+yCxvwTo UkgOpWcVeBEp1cRYiFvU8EaJFTyakxgKpDV7lBTBzUdYnh2gL7CDkyn+Bnb1hcn4kM ocGjy9acslaXDDhwONidiibbFVOlelqJO0pACSVw= X-KTH-mail-from: maandree@kth.se Received: from localhost.localdomain (h220n13-jak-a12.ias.bredband.telia.com [81.228.219.220]) by smtp-3.sys.kth.se (Postfix) with ESMTPSA id 7F39026B4; Tue, 5 Apr 2016 20:36:22 +0200 (CEST) Date: Tue, 5 Apr 2016 20:36:07 +0200 From: Mattias =?UTF-8?B?QW5kcsOpZQ==?= To: Eric Blake Subject: Re: bug#23222: test: incorrect operator-precedence Message-ID: <20160405203607.45bfc97b.maandree@kth.se> In-Reply-To: <5703D534.7050505@redhat.com> References: <20160405135716.0cce3e8c.maandree@kth.se> <5703D534.7050505@redhat.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-unknown-linux-gnu) X-Awesomeness: 120 % User-Agent: Claws Mail X-Operating-System: GNU/Linux MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/EWgBzfhdg4WuUw/6F_aF8Qb"; protocol="application/pgp-signature" X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: 23222 X-Mailman-Approved-At: Tue, 05 Apr 2016 14:38:26 -0400 Cc: 23222@debbugs.gnu.org, Mattias =?UTF-8?B?QW5kcsOpZQ==?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --Sig_/EWgBzfhdg4WuUw/6F_aF8Qb Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 5 Apr 2016 09:09:40 -0600 Eric Blake wrote: > tag 23222 confirmed > thanks >=20 > On 04/05/2016 05:57 AM, Mattias Andr=C3=A9e wrote: > > Failing test-case #1: > >=20 > > ./test -n -a -n > >=20 > > fails and outputs > >=20 > > ./test: extra argument =E2=80=98-n=E2=80=99 > >=20 > > Expected behaviour is silent success, as seen in > > Bash's implementation. =20 >=20 > Thanks for the report. POSIX indeed says that -a is a > binary primary, and also says that > "3 arguments: > If $2 is a binary primary, perform the binary > test of $1 and > $3." (http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html) >=20 > So by that reading, coreutils MUST parse your expression > as: >=20 > test \( -n \) -a \( -n \) >=20 > whereas it appears that coreutils has instead > accidentally parsed it as: >=20 > test \( -n -a \) -n >=20 > Not everyday someone finds a real bug in 'test'! >=20 > That said, POSIX _also_ says that portable scripts MUST > NOT use -a or -o; it is inherently ambiguous. >=20 > You are better off fixing your script to use: >=20 > test -n && test -n >=20 > whether or not someone is able to quickly patch > coreutils' bug. I'm not actually using -a, -o, (, ), and !. I just noticed the bug by running some test-cases. >=20 >=20 > >=20 > > Explanation: -a has higher precedence than -n. =20 >=20 > Not quite true. The POSIX rules state that -a is > optional (non-XSI systems don't even have to have it), > and that precedence has no bearing (rather, it is whether > you have exactly three arguments that determines whether > -a must be used in its role as a binary operator). >=20 >=20 > >=20 > > Failing test-case #2: > >=20 > > ./test ! '' -a '' > >=20 > > shall fail (exit value 1), but in this > > implementation it succeeds. =20 >=20 > Sorry, but here, you're wrong. POSIX states: >=20 > "4 arguments: > If $1 is '!', negate the three-argument test of > $2, $3, and $4." >=20 > which means this parses as: >=20 > test ! \( '' -a '' \) >=20 > or as: >=20 > test ! \( \( '' \) -a \( '' \) \) >=20 > The negation of 'false and false' is true, so the exit > status is correctly 0. >=20 >=20 > >=20 > > Explanation: ! has higher precedence than -a, =20 >=20 > Wrong. As mentioned above, the rules are based not on > precedence, but on how many operands are present. >=20 XSI-conformant systems shall use the following precedence rules (highest to lowest), as documented (not quite as clearly) in the POSIX specifications: * parentheses (1) * string binary primaries * unary non-string primaries * algebraic binary primaries (2) * unary string primary with * (3) * ! * -a * -o * (4) in that order but not necessarily directly followed by each other somewhere between (1) and (2), and with other binary primitives somewhere between (3) and (5). The POSIX specification does indeed that that the number of arguments shall determine the precedence for 1 to 4 arguments. And the given rules do conflict with XSI. But if we run test \( \( ... \) \) instead of test it seems only reasonable to use the XSI rules. Is it too much to ask that test ... gives the same result? Your implementation appear to be unaffected if it is given extra parentheses in this way. But it does evaluate test ! \( '' \) -a \( '' \) as expected. It is very weird that test ! \( '' \) -a \( '' \) and test ! '' -a '' do not give the same result. I believe that POSIX rule for 4 arguments shall be disregarded. It is clearly only intended for other binary operators than logical operators. --Sig_/EWgBzfhdg4WuUw/6F_aF8Qb Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXBAWXAAoJEM4wYJDpiwjHMfsQAJqt0rV6nrr4kR8G9O0bARzr hSkoZ4e0S6sB5CHBiKJSPqaxW0rZ5VWQHGor1X8JaTsb/HYWnxd96C+qhmHufvyd +BJZe3h5Hyv+lDTaxuhhtwufapMtcI1I8lUg2qmaQtrOusvyi5U256hWtCbtkeSS 4hqrx7qGYQNOlAu+eYQjJSWIKtsn5QMe3d6veV3tPPu2O1nXRZeCp5a2f486h5NE EkEqHLo3FEf6B34Hnwk1PRanT8ZeH6kGs73d3O5koy1/ctsXJeLCf//zICFqfbBR FrlV0JLIA0VqezMiUijPZJiIceAZi0TRhB5CmbLQ/o/8doZuyDmWCbc8CmdUo6Qj lxtFyLX3n2w2vAOS9uXriUhorImuJj9uQyDPu9MJYEXUDO0jh7IB+5LbrOWup84M Bfn3gRVTwlO8/yTpd87FE15zgwVnimvD1n9yk36RKrlJpqn0EzKHdfbWsVOcGEJw fA8efBc3yil53S/SjpD37OQpnZhswo7r5SQKEle9lD0YenmbxKHBgk2BRsktSgSf qy7qBxOUYNvxua/Jpg2eboyOLcdbJ6bZVxlbhd4fWZq+xJpVxEztwkuru5Q6pN/6 QOZOmLMp9T/F9P6qsOZYTlHdV+p8IGCwI4icJxz1nYYdGiF46JlT3al/JdVHvttB 7eACLzzuIBpHQdufbz+z =WJxf -----END PGP SIGNATURE----- --Sig_/EWgBzfhdg4WuUw/6F_aF8Qb-- From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 05 15:15:49 2016 Received: (at 23222) by debbugs.gnu.org; 5 Apr 2016 19:15:49 +0000 Received: from localhost ([127.0.0.1]:50660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anWS5-0008Pc-7u for submit@debbugs.gnu.org; Tue, 05 Apr 2016 15:15:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39899) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anWS3-0008J1-BZ for 23222@debbugs.gnu.org; Tue, 05 Apr 2016 15:15:47 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFEED80F62; Tue, 5 Apr 2016 19:15:41 +0000 (UTC) Received: from [10.3.113.124] (ovpn-113-124.phx2.redhat.com [10.3.113.124]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u35JFeU8028844; Tue, 5 Apr 2016 15:15:40 -0400 Subject: Re: bug#23222: test: incorrect operator-precedence To: =?UTF-8?Q?Mattias_Andr=c3=a9e?= References: <20160405135716.0cce3e8c.maandree@kth.se> <5703D534.7050505@redhat.com> <20160405203607.45bfc97b.maandree@kth.se> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <57040EDB.9090307@redhat.com> Date: Tue, 5 Apr 2016 13:15:39 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <20160405203607.45bfc97b.maandree@kth.se> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="H4Sv6PEJepov1B2HAfudofSKvgK5TDLlo" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: 23222 Cc: 23222@debbugs.gnu.org, =?UTF-8?Q?Mattias_Andr=c3=a9e?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --H4Sv6PEJepov1B2HAfudofSKvgK5TDLlo Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/05/2016 12:36 PM, Mattias Andr=C3=A9e wrote: >> Sorry, but here, you're wrong. POSIX states: >> >> "4 arguments: >> If $1 is '!', negate the three-argument test of >> $2, $3, and $4." >> >> which means this parses as: >> >> test ! \( '' -a '' \) >> >=20 > XSI-conformant systems shall use the following precedence > rules (highest to lowest), as documented (not quite as clearly) > in the POSIX specifications: >=20 Only for more than four arguments: >4 arguments: The results are unspecified. [OB XSI] [Option Start] On XSI-conformant systems, combinations of primaries and operators shall be evaluated using the precedence and associativity rules described previously. In addition, the string comparison binary primaries '=3D' and "!=3D" shall have a higher preceden= ce than any unary primary. [Option End] > The POSIX specification does indeed that that > the number of arguments shall determine the > precedence for 1 to 4 arguments. And the given > rules do conflict with XSI. But if we run >=20 > test \( \( ... \) \) instead of test it seems > only reasonable to use the XSI rules. Yeah, other than the fact that -o and -a are marked obsolescent by POSIX because they are inherently ambiguous, and therefore "The results are unspecified" is a better phrase to rely on than any particular precedence= =2E > I believe that POSIX rule for 4 arguments shall > be disregarded. It is clearly only intended for > other binary operators than logical operators. Sorry, but that's not how POSIX is worded. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --H4Sv6PEJepov1B2HAfudofSKvgK5TDLlo Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXBA7bAAoJEKeha0olJ0NqLUsIAIQaiwvim4erGdU3Y16sDfxO wr6+0WjSQ7CedhirhJwnu2x2deL4aWnE2WB117Rrqr7dj1i8zRO7O7BOKuWIqVbM L/3V989K5Axp0lACzJx3TJsex6zZsQDheEJQD0vaD8hIZCiAnRZ9VMP8Tg/cNlU3 GuFAxf37aTdOwYi26ITucN2mLVEUwwqUKGRPqDNyBRlGtfVcBVyZnz0IRkJLTAIP u27/TUw4ySgJLD6Zb1Xj1lKbhxfWlAZWP73pAkNuqAohKZzHNQ3Q3DkQJteFPo/q e5QFqR+an1iIy8p3xmWkk5RbtoYf0jx0EwMEknna9QHEB9Dw5OYwYcp7fUAw3Rw= =ZmSc -----END PGP SIGNATURE----- --H4Sv6PEJepov1B2HAfudofSKvgK5TDLlo-- From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 30 00:14:53 2018 Received: (at 23222) by debbugs.gnu.org; 30 Oct 2018 04:14:53 +0000 Received: from localhost ([127.0.0.1]:52966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHLQb-0004Lg-3u for submit@debbugs.gnu.org; Tue, 30 Oct 2018 00:14:53 -0400 Received: from mail-pg1-f172.google.com ([209.85.215.172]:41760) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHLQZ-0004LN-FX; Tue, 30 Oct 2018 00:14:51 -0400 Received: by mail-pg1-f172.google.com with SMTP id 23-v6so4953793pgc.8; Mon, 29 Oct 2018 21:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=waTr3Td1L9jXxwUD9a6j9IdjTPaOY0sukg/LVLz2k+c=; b=UGLqUt27TTbGK0eL4jCmqWYXaXptozCEw6no8X8F7OZz0OY2ADUW3O8wd5RvAch5cy fiyBSqQTBRijt4uJPJOlio06wG2Z9MP+gfaOYL4dyG5SlG/7lQDSLF0c7CRjcZa+y9NU 4HhtdJMvHLTlu92KIer/wCnVQ3/A9nJOdHpvp8weCZJa0t445WqEEgDUtXWH4ztPNwoH 66fLH/xjMRBxj1Jlv5ap7o6REAkvTFKyscCvufLyW5fQMTJ1zDkc/9KaUSrZ/SWqmaNK 94VUlx+CMjmvom3YV53yIsskWisEEa/DJ63vtEjIx2oiF+oqRLgaTNUc8H0dGxhb5QNI B/yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=waTr3Td1L9jXxwUD9a6j9IdjTPaOY0sukg/LVLz2k+c=; b=RdQP3CymIgyc/LLTqlXHjN1Jn1c/oA+Px29DJJXxAObuQU2O4gkbVSu6PwBkbtvqp2 WeRxpilHH9yZ2nRL2vgUSKIwu3xWPmqxu+XRClcQEfClXQ2CN4loR85wzKOI1LZ4RxJp MkltzAhxuvuUhYvg+4QT46hmDf/PIr9NHfS4UahNnUbaM3SCXfjC/xhW6+TofUnG+jht Gi8TYVkxld5O9jc4IYemnadkYu5teUWr3mTchfC374ZAwqYv5UDq5kMXOd9tTO50Kf03 t2zOYb54zj5woiYx9YwOXbKKphYrrehA8qJi3BtDBwNw7bAGOHxF/cHZTr3F0THUD9fv p5OA== X-Gm-Message-State: AGRZ1gJr2xmr5cSxCZ0bl3aWuuw5hs5KnaGpUu6NC0azXWBLErCBus97 CD/fZCQdsESHpEJyEx5AWI1M/W9vh8o= X-Google-Smtp-Source: AJdET5dyZzGI9FMRV+pL+Rlb8qsu/k6VpM6L82lwbOVKZY3GFkWp8euZiphDNjdtFY6qXor4d/DEDg== X-Received: by 2002:a62:c6c8:: with SMTP id x69-v6mr1293068pfk.37.1540872884784; Mon, 29 Oct 2018 21:14:44 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id e12-v6sm450350pff.5.2018.10.29.21.14.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 21:14:43 -0700 (PDT) Subject: Re: bug#23222: test: incorrect operator-precedence To: 23222@debbugs.gnu.org References: <20160405135716.0cce3e8c.maandree@kth.se> <5703D534.7050505@redhat.com> From: Assaf Gordon Message-ID: Date: Mon, 29 Oct 2018 22:14:42 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <5703D534.7050505@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 23222 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 23222 fixed close 23222 stop On 2016-04-05 9:09 a.m., Eric Blake wrote: > tag 23222 confirmed > thanks > > On 04/05/2016 05:57 AM, Mattias Andrée wrote: >> Failing test-case #1: >> >> ./test -n -a -n >> >> fails and outputs >> >> ./test: extra argument ‘-n’ >> >> Expected behaviour is silent success, as seen in >> Bash's implementation. > > Thanks for the report. POSIX indeed says that -a is a binary primary, > and also says that With this recent commit: test: remove support for the ambigous -a unary operator https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=88c32fa68ee7057744bfb6d41f6e8eb68801306f test(1) no longer accepts unary "-a". Closing this item as "fixed". -assaf From unknown Mon Aug 18 04:42:46 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 27 Nov 2018 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator