freebsd-skq/usr.bin/grep
kevans fcd2c3120c bsdgrep(1): various fixes of empty pattern/exit code/-c behavior
When an empty pattern is encountered in the pattern list, I had previously
broken bsdgrep to count that as a "match all" and ignore any other patterns
in the list. This commit rectifies that mistake, among others:

- The -v flag semantics were not quite right; lines matched should have been
  counted differently based on whether the -v flag was set or not. procline
  now definitively returns whether it's matched or not, and interpreting
  that result has been kicked up a level.
- Empty patterns with the -x flag was broken similarly to empty patterns
  with the -w flag. The former is a whole-line match and should be more
  strict, only matching blank lines. No -x and no -w will will match the
  empty string at the beginning of each line.
- The exit code with -L was broken, w.r.t. modern grep. Modern grap will
  exit(0) if any file that didn't match was output, so our interpretation
  was simply backwards. The new interpretation makes sense to me.

Tests updated and added to try and catch some of this.

This misbehavior was found by autoconf while fixing ports found in PR 229925
expecting either a more sane or a more GNU-like sed.

MFC after:	1 week
2019-09-25 17:14:43 +00:00
..
tests bsdgrep(1): add some basic tests for some GNU Extension support 2019-09-03 18:32:29 +00:00
file.c bsdgrep(1): Evict character sequence that moved in 2018-06-08 12:58:55 +00:00
grep.1 Adjust formatting of grep and zgrep manual pages. 2018-08-20 22:23:59 +00:00
grep.c bsdgrep(1): various fixes of empty pattern/exit code/-c behavior 2019-09-25 17:14:43 +00:00
grep.h bsdgrep(1): Slooowly peel away the chunky onion 2018-06-08 01:25:07 +00:00
Makefile Fix bsdgrep manpage clobbering grep(1) with default build options 2019-01-09 02:47:07 +00:00
Makefile.depend
queue.c
util.c bsdgrep(1): various fixes of empty pattern/exit code/-c behavior 2019-09-25 17:14:43 +00:00
zgrep.1 Adjust formatting of grep and zgrep manual pages. 2018-08-20 22:23:59 +00:00
zgrep.sh Fix exit code for mismatches after r333013. 2018-05-24 22:15:47 +00:00