[comp.sources.d] egrep with -i option ????

wnp@iiasa.AT (Wolf PAUL) (06/19/91)

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

I.e. an egrep with the following synopsis:

egrep [ -bchilnsv ] [ -e expr ] [ -f fname ] [ expr ] [ fname... ]

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.


-- 
W.N.Paul
IIASA, wnp@iiasa.iiasa.ac.at, +43-2236-71521-465  (till Jul 26, 1991)
ALCATEL/ELIN, cc_wnp@rcvie.at (as of Jul 29, 1991)
Home Phone: +43-2236-618514 (till Jun 30, 1991), +43-1-224-6913 (as of Jul 1)

wittig@gmdzi.gmd.de (Georg Wittig) (06/20/91)

wnp@iiasa.AT (Wolf PAUL) writes:

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

Get the GNU grep
-- 
Georg Wittig   GMD-Z1.IT   P.O.Box 1240 | "Freedom's just another word
D-W-5205 St. Augustin 1	   (Germany)	|  for nothing left to lose"
email:		wittig@gmdzi.gmd.de	| (from "Me and Bobby McGee",
telephone:	(+49) 2241 14-2294	|  Janis Joplin, Kris Kristofferson)

guy@auspex.auspex.com (Guy Harris) (06/21/91)

>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.)