freebsd-skq/contrib/netbsd-tests/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
..
d_basic.out
d_begin_end_a.out
d_begin_end_b.out
d_binary.out
d_color_a.in
d_color_a.out
d_color_b.in
d_color_b.out
d_color_c.out
d_context2_a.out
d_context2_b.out
d_context2_c.out
d_context_a.in
d_context_a.out
d_context_b.in
d_context_b.out
d_context_c.out
d_context_d.out
d_context_e.in bsdgrep: fix -w flag matching with an empty pattern 2017-05-02 20:39:33 +00:00
d_context_e.out bsdgrep: fix -w flag matching with an empty pattern 2017-05-02 20:39:33 +00:00
d_context_f.out bsdgrep: fix -w flag matching with an empty pattern 2017-05-02 20:39:33 +00:00
d_context_g.out bsdgrep: fix -w flag matching with an empty pattern 2017-05-02 20:39:33 +00:00
d_egrep.out
d_escmap.in
d_f_file_empty.in
d_file_exp.in
d_file_exp.out
d_ignore_case.out
d_input
d_invert.in
d_invert.out
d_oflag_zerolen_a.in
d_oflag_zerolen_a.out
d_oflag_zerolen_b.in
d_oflag_zerolen_b.out
d_oflag_zerolen_c.in
d_oflag_zerolen_c.out
d_oflag_zerolen_d.in
d_oflag_zerolen_e.in
d_oflag_zerolen_e.out
d_recurse_symlink.err
d_recurse_symlink.out
d_recurse.out
d_whole_line.out
d_word_regexps.out
d_zgrep.out
t_grep.sh bsdgrep(1): various fixes of empty pattern/exit code/-c behavior 2019-09-25 17:14:43 +00:00