freebsd-dev/usr.bin/grep
Kyle Evans 38325e2ab8 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 DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
queue.c various: general adoption of SPDX licensing ID tags. 2017-11-27 15:37:16 +00:00
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