Date: Tue, 4 Jun 1996 19:27:07 +0200 From: Wolfram Schneider <wosch@cs.tu-berlin.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 Message-ID: <199606041727.TAA01503@campa.panke.de> In-Reply-To: <199606040947.LAA21894@uriah.heep.sax.de> References: <199606031939.MAA26616@george.lbl.gov> <199606040947.LAA21894@uriah.heep.sax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606041727.TAA01503>
