From owner-freebsd-bugs Tue Dec 24 14:40:05 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id OAA07826 for bugs-outgoing; Tue, 24 Dec 1996 14:40:05 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id OAA07815; Tue, 24 Dec 1996 14:40:02 -0800 (PST) Resent-Date: Tue, 24 Dec 1996 14:40:02 -0800 (PST) Resent-Message-Id: <199612242240.OAA07815@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, tarush@mindspring.com 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 ; 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 ; 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 X-Send-Pr-Version: 3.2 Subject: bin/2276: /bin/test bug Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 2276 >Category: bin >Synopsis: /bin/test bug >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Dec 24 14:40:01 PST 1996 >Last-Modified: >Originator: Tom Rush >Organization: Tom Rush tarush@mindspring.com >Release: FreeBSD 2.1.5-RELEASE i386 >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); >Audit-Trail: >Unformatted: