expr(1) fails on negative arguments (with fix)

Tony L. Hansen hansen at pegasus.UUCP
Sat Jun 14 04:00:05 AEST 1986


<	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



More information about the Net.bugs.v7 mailing list