Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: 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 Xref: watmath net.bugs.usg:503 net.bugs.4bsd:2164 net.bugs.v7:232 net.bugs.2bsd:370 Summary: System V fixed the problem < 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