Date: Tue, 24 Dec 1996 17:36:18 -0500 (EST) From: tarush@mindspring.com To: FreeBSD-gnats-submit@freebsd.org Subject: bin/2276: /bin/test bug Message-ID: <199612242236.RAA04058@tarush.mindspring.com> Resent-Message-ID: <199612242240.OAA07815@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612242236.RAA04058>