From owner-freebsd-bugs Tue Jun 4 11:41:03 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id LAA02896 for bugs-outgoing; Tue, 4 Jun 1996 11:41:03 -0700 (PDT) Received: from mail.cs.tu-berlin.de (root@mail.cs.tu-berlin.de [130.149.17.13]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id LAA02780 for ; Tue, 4 Jun 1996 11:39:08 -0700 (PDT) Received: from campa.panke.de (anonymous224.ppp.cs.tu-berlin.de [130.149.17.224]) by mail.cs.tu-berlin.de (8.6.12/8.6.12) with ESMTP id UAA03497; Tue, 4 Jun 1996 20:13:17 +0200 Received: (from wosch@localhost) by campa.panke.de (8.6.12/8.6.12) id TAA01503; Tue, 4 Jun 1996 19:27:07 +0200 Date: Tue, 4 Jun 1996 19:27:07 +0200 From: Wolfram Schneider Message-Id: <199606041727.TAA01503@campa.panke.de> To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) Cc: jin@george.lbl.gov (Jin Guojun[ITG]), bugs@freebsd.org, problem@bsdi.com Subject: Re: sh bug In-Reply-To: <199606040947.LAA21894@uriah.heep.sax.de> References: <199606031939.MAA26616@george.lbl.gov> <199606040947.LAA21894@uriah.heep.sax.de> Reply-to: Wolfram Schneider MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk J. Wunsch writes: >Our test(1) implementation fully agrees with Posix.2: agrees != do the right thing BTW, $ /bin/test \( e = -e \) test: syntax error: Undefined error: 0 I think FreeBSD should change the implementation of test(1). Wolfram Index: test.c =================================================================== RCS file: /a/cvs/src/bin/test/test.c,v retrieving revision 1.13 diff -u -r1.13 test.c --- 1.13 1996/03/11 11:01:03 +++ test.c 1996/06/04 16:34:24 @@ -198,7 +198,9 @@ if (opname[0] == '(' && opname[1] == '\0') { nest += NESTINCR; continue; - } else if (*ap && (op = lookup_op(opname, unary_op)) >= 0) { + } else if (*ap && (op = lookup_op(opname, unary_op)) >= 0 && + lookup_op(*ap, binary_op) < 0 && + strcmp(*ap, ")" )) { if (opsp == &opstack[0]) overflow(); --opsp; > > The algorithm for determining the precedence of the operators and the 1 > return value that shall be generated is based on the number of arguments 1 > presented to test. (However, when using the [...] form, the right- 1 > bracket final argument shall not be counted in this algorithm.) In the 1 > following list, $1, $2, $3, and $4 represent the arguments presented to 1 > test. 1 > > 0 arguments: 1 >... > 1 argument: 1 >... > 2 arguments: 1 >... > 3 arguments: 1 > > - If $2 is a binary primary, perform the binary test of $1 and 2 > $3. 2 > > - If $1 is !, negate the two-argument test of $2 and $3. 1 > > - Otherwise, produce unspecified results. 1 > > 4 arguments: 1 > > - If $1 is !, negate the three-argument test of $2, $3, and $4. 1 > > - Otherwise, the results are unspecified. 1 > > >4 arguments: 1 > > The results are unspecified. 1 > > >The ``> 4 arguments'' is the case you are complaining about. As you >can see, it's up to the implementation of the test command to decide >about the operator precedence. It apparently decides that the first >operator is to be taken as the -h flag (test for a symbolic link), and >the following equation sign is taken as the filename argument to -h. >The remaining arguments finally result in a syntax error.