egrep with -i option ????

Guy Harris guy at auspex.auspex.com
Fri Jun 21 09:07:30 AEST 1991


>Does anyone have a freely-distributable version of egrep which
>is compatible with the egrep in SunOS 4.x ?

Well, SunOS 4.x picked up the idea from the S5R3 "egrep"; in fact, its
"egrep" is based on the S5R3 one.  (Its *implementation* of "egrep -i"
isn't, because the S5R3 one's implementation is Really Stupid.)

4.3-reno has a "grep" package done by James A. Woods; it doesn't have
the Berkeley "AT&T-free" copyright, but I suspect this may just be an
oversight - check out some archive site, if there's one nearby, that has
the "AT&T-free BSD" stuff.  It supports the "-i" flag (and doesn't
appear to do it the Really Stupid way, which isn't surprising - jaw
knows what he's doing).

>On our Ultrix-3 system, egrep does not support the -i (ignore case)
>option, nor does the 4.3BSD source we have here. It does not seem
>trivial to me to add -i support to egrep.y.

It's not that bad.  If "-i" is set, just map the entire input pattern to
lower case before processing it, and then after you've processed it,
make the goto function entries for all the upper-case letters be the
same as the ones for the lower-case letters.  No need to map the input
to lower case as the S5R3 one does....

(In effect, this is equivalent to replacing all letters in the pattern
with regular expressions matching the upper-case or lower-case versions
of the letters before compiling the pattern.)



More information about the Comp.unix.questions mailing list