From tarush@mindspring.com  Tue Dec 24 14:34:53 1996
Received: from mule1.mindspring.com (mule1.mindspring.com [204.180.128.167])
          by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id OAA07606
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 24 Dec 1996 14:34:52 -0800 (PST)
Received: from tarush.mindspring.com (user-168-121-119-56.dialup.mindspring.com [168.121.119.56]) by mule1.mindspring.com (8.8.2/8.7.3) with ESMTP id WAA36314 for <FreeBSD-gnats-submit@freebsd.org>; Tue, 24 Dec 1996 22:34:48 GMT
Received: (from tarush@localhost) by tarush.mindspring.com (8.7.5/8.6.12) id RAA04058; Tue, 24 Dec 1996 17:36:18 -0500 (EST)
Message-Id: <199612242236.RAA04058@tarush.mindspring.com>
Date: Tue, 24 Dec 1996 17:36:18 -0500 (EST)
From: tarush@mindspring.com
Reply-To: tarush@mindspring.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: /bin/test bug
X-Send-Pr-Version: 3.2

>Number:         2276
>Category:       bin
>Synopsis:       /bin/test bug
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    steve
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 24 14:40:01 PST 1996
>Closed-Date:    Tue Dec 24 16:08:27 PST 1996
>Last-Modified:  Tue Dec 24 16:10:06 PST 1996
>Originator:     Tom Rush
>Release:        FreeBSD 2.1.5-RELEASE i386
>Organization:
Tom Rush
tarush@mindspring.com
>Environment:
AMD 486-DX4/100, 16 mb
FreeBSD-2.1.5 (the same problem exists in -current)
>Description:
/bin/test does not handle the -a and -o operators properly in the
3-argument case, i.e., test "string1" -o "string2".  The special case
code at the top of main() passes this expression to posix_binary_op(),
which doesn't do anything special for these operators; and test returns
0 (true) in any case.

>How-To-Repeat:
Using shell vars:  V_ONE and V_TWO are unset (or null)
test "$V_ONE" --> 1 (ok)
test "$V_TWO" --> 1 (ok)
test "$V_ONE" -o "$V_TWO" --> 0 (wrong)
V_ONE="hello"
test "$V_ONE" -o "$V_TWO" --> 0 (ok)
test "$V_ONE" -a "$V_TWO" --> 0 (wrong)
V_TWO="goodbye"
test "$V_ONE" -a "$V_TWO" --> 0 (ok)

>Fix:
Let these and/or expressions drop through to the parser instead of
sending to posix_binary_op().

--- test.c.orig	Sat Dec 14 06:11:34 1996
+++ test.c	Mon Dec 23 22:47:13 1996
@@ -157,7 +157,7 @@
 			ret_val = posix_unary_op(&argv[1]);
 			if (ret_val >= 0)
 				return (!ret_val);
-		} else {
+		} else if (lookup_op(argv[2], andor_op) < 0) {
 			ret_val = posix_binary_op(&argv[1]);
 			if (ret_val >= 0)
 				return (ret_val);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Tue Dec 24 16:08:27 PST 1996 
State-Changed-Why:  
Fixed in rev 1.15 of test.c.  Thanks for the patch. 
>Unformatted:
