[net.unix-wizards] bug/inconsistancy in *grep

tim@dciem.UUCP (Tim Pointing) (02/09/84)

There is an inconsistancy in the way "-v" is handled in the V7 grep's
(fgrep/egrep/grep). The "-v" flag should, in my humble opinion, invert
the exit status of grep. I.e. if every line does contain the pattern
(grep -v doesn't pass any lines to stdout), then the exit status of grep
should indicate failure. If "grep" fails then "grep -v" shouldn't fail!.

I hesitate in fixing this at our site since this could cause problems for
scripts that are sent to/from us. Does anybody know if this "misfeature"
has been fixed in 4.?/SIII/SV  ?



tomorrow I'll get around to doing what should have been done yesterday...
-- 
	Tim Pointing, DCIEM
	{allegra,ubc-vision,linus,ihnp4,uw-beaver,floyd}!utcsrgv!dciem!tim
or	{allegra,ihnp4,linus,decvax}!utzoo!dciem!tim

henry@utzoo.UUCP (Henry Spencer) (02/11/84)

Tim Pointing complains:

  There is an inconsistancy in the way "-v" is handled in the V7 grep's
  (fgrep/egrep/grep). The "-v" flag should, in my humble opinion, invert
  the exit status of grep. I.e. if every line does contain the pattern
  (grep -v doesn't pass any lines to stdout), then the exit status of grep
  should indicate failure. If "grep" fails then "grep -v" shouldn't fail!.

Are you looking at the code or the documentation?  The behavior that you
seek is exactly the way egrep, grep, and fgrep really do behave on our
system, which is essentially vanilla V7.  The original Bell manual page
botched the description of this, but the programs do things right.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry