Subject: Re: bin/12838: new expr(1) is totally broken
To: None <ross@ghs.com>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 05/04/2001 21:14:34
[ On Friday, May 4, 2001 at 16:30:01 (-0700), Ross Harvey wrote: ]
> Subject: bin/12838: new expr(1) is totally broken

Actually `expr' is not "totally broken" -- it simply has an operator
precedence error.

This seems to fix the bug, though only using your one example to test:

Index: expr.y
===================================================================
RCS file: /cvs/NetBSD/src/bin/expr/expr.y,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 expr.y
*** expr.y      2001/03/25 05:48:23     1.1.1.2
--- expr.y      2001/05/05 01:09:52
***************
*** 66,72 ****
  %token STRING
  %left SPEC_OR
  %left SPEC_AND
! %left COMPARE ARITH_OPERATOR SPEC_REG
  %left LEFT_PARENT RIGHT_PARENT
  
  %%
--- 66,73 ----
  %token STRING
  %left SPEC_OR
  %left SPEC_AND
! %left COMPARE
! %left ARITH_OPERATOR SPEC_REG
  %left LEFT_PARENT RIGHT_PARENT
  
  %%

> 	Don't replace software that has been tested for years with casually
> 	done rewrites. Fix the bugs. Change is the enemy of reliability.

That's pretty funny!  :-)  NOT!

Seriously speaking all complex software should be re-written from
scratch as often as humanly and economically possible.  And maybe even
more often than that.  (of course `expr' is not exactly "complex",
but...)

Seriously, the old `expr' did need replacing.  It had bugs of its own
and broke several of my own scripts -- scripts that had worked on many
other unix and unix-like systems.

The new version is now at a point where bug reports like yours can be
used to improve it.

> 	Don't commit widely used tools in critical paths without basic
> 	testing. (Never mind, _serious_ testing.)

Perhaps you're willing to write some test harnesses, test cases, etc.?

Not everyone in the world does everything possible with even a
relatively simple tool such as expr.  Dozens, and maybe even hundreds,
of us have been using the enw version of expr for quite some time now
and few have had any complaints about it.  The bugs that have been
reported have been fixed so far as I can see.

In any case I'm quite sure that the new version did go through extensive
and very serious testing even before it was committed.

It is interesting to note that the FreeBSD folks never took JTC's
initial rewrite as a hand-coded recursive descent parser but instead of
just incrementally improved the original 1993 version.

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>     <woods@robohack.ca>
Planix, Inc. <woods@planix.com>;   Secrets of the Weird <woods@weird.com>