Subject: Re: Replacement for grep(1) (part 2)
To: None <,,>
From: Jamie Howard <>
List: tech-userlevel
Date: 07/05/1999 21:14:36
Due to the number of fixes I have received over the past few days, I
decided to put together a new release of grep.  It was either this or 
watch _Titanic_ on Cinemax.

I incorporated a huge patch from Dag-Erling Smorgrav which as he put it
"cleaned it up to make it conform to FreeBSD's coding style standards. I
also removed a bunch of unused or unnecessary variables, fixed one or two
minor bugs, and made a few entirely subjective cosmetic improvements."  He
also modified the Makefile to generate links for fgrep and egrep as well.
All things I was going to worry with when it was done.  :)  I added the
links for zgrep.  I changed the sample length in the binary checker from
64 bytes to 32 at his suggestion.  This is the same as how GNU grep
handles it.

I changed it so that even when called as grep or with -G, it treats the
pattern as an extended regular expression.  GNU grep behaves the same way.

Simon Burge sent code to enable -w as well as several smaller code fixes
and clean ups.

I changed bin_file() and seekable() to operate on a pointer to a FILE
rather than on an integer file descriptor.

Due to popular demand, I added support for searching gzip compressed
files.  GNU grep only supports searching gzip compressed files.  It did
not bloat my code as much as I expected; I vapor locked and forgot about
libz, which did all the hard work for me.  It would be trivial to add
support for bzip and bzip2 files for those OSes that have libbz2.

Archie Cobbs dropped the hint needed to solve the problems with -x.  Right
now, I wrap the pattern with "^(" and ")$".  I know GNU grep does this,
but is this correct?

Now, as it stands, I beleive this implementation is identical to GNU grep,
except for the added -o option, and the -A num, -B num, -C, and -num
family of options.  Despite what I said before, I will implement them.
Another popular demand thing.  So I will take care of that over the next
few days.

It would be really swank if someone were to go over what I have and make
sure it is correct.  I know I was blowing $ before, and I think that is
correct now.

Due to problems with the previous download site (it is down as I type
this), I will place this file in two locations:

It will probably be slow to hit the second, as it may be down until
tomorrow morning.

Thank you everyone who helped,