[net.bugs.v7] An expr bug/misfeature

guy@sun.uucp (Guy Harris) (06/19/86)

> > < 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?
> 
> > (fixed in S5) Sorry, but I haven't looked at the expr code to see what
> > the real fix was.
> 
> It may have been to rewrite the whole thing in C.  It had been so rewritten
> as of S3, although the S3 version still maintained the old "index",
> "substr", and "length" operators from V7, which were undocumented and caused
> confusion if those names appeared as operands.  S5 ripped them out.

Unfortunately, they did NOT rip out the "match" operator, which is a prefix
synonym for the infix ":" operator.  As such,

	expr match : "[a-z]atch"

gets a "syntax error" message, while

	expr hatch : "[a-z]atch"

doesn't.  The person who deleted them must have been confused, and figured
"match" had to stay in because its infix equivalent was still there.

Of course, even if you rip "match" out, 

	expr : : "[a-z]atch"

still gets a "syntax error", so "expr" can't do mattern matching on
arbitrary strings.  Be warned.
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com (or guy@sun.arpa)