Article View: net.bugs.usg
Article #315Re: expr(1) fails on negative arguments (with fix)
From: Tony L. Hansen
Date: Fri, 13 Jun 1986 18:00
Date: Fri, 13 Jun 1986 18:00
28 lines
1529 bytes
1529 bytes
< expr(1) fails to handle negative arguments correctly. < In particular, arithmetic operators will not accept < negative arguments. Additionally, comparison operators < use string comparison instead of arithmetic comparison < if the second argument is negative. Like so many other things, this bug was fixed in System V. My UNIX System Vr2 machine gives the following answers: < expr 0 + -1 < non-numeric argument -1 < expr -2 \> -1 < 1 0 < Nice fix. Try "expr -5 * ---6". The problem cannot be correctly fixed w/out < going all out and implementing UMINUS is the yacc grammar. Any takers? < expr -5 \* ---6 expr: non-numeric argument < expr -5 \* -6 30 Sorry, but I haven't looked at the expr code to see what the real fix was. Tony Hansen ihnp4!pegasus!hansen
Technical Details
Message-ID:
<2795@pegasus.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!ihnp4!pegasus!hansenReferences:
<270@cirl.UUCP> <219@decvax.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!ihnp4!pegasus!hansen From: hansen@pegasus.UUCP (Tony L. Hansen) Newsgroups: net.bugs.usg,net.bugs.4bsd,net.bugs.v7,net.bugs.2bsd Subject: Re: expr(1) fails on negative arguments (with fix) Message-ID: <2795@pegasus.UUCP> Date: Fri, 13-Jun-86 14:00:05 EDT Article-I.D.: pegasus.2795 Posted: Fri Jun 13 14:00:05 1986 Date-Received: Tue, 17-Jun-86 19:04:45 EDT References: <270@cirl.UUCP> <219@decvax.UUCP> Reply-To: hansen@pegasus.UUCP (60545457-Tony L. Hansen;LZ 3B-315;6243) Distribution: net Organization: AT&T-IS Labs, Lincroft, NJ Lines: 28 Keywords: expr, System V Summary: System V fixed the problem