[Bug 253209] grep -v -f some-empty-file -- does the wrong thing
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Thu Feb 11 02:50:54 UTC 2021
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253209
--- Comment #3 from commit-hook at FreeBSD.org ---
A commit in branch stable/13 references this bug:
URL:
https://cgit.FreeBSD.org/src/commit/?id=574d0dfae5011a766aa967f1d1675ddf7b535936
commit 574d0dfae5011a766aa967f1d1675ddf7b535936
Author: Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2021-02-04 21:26:45 +0000
Commit: Kyle Evans <kevans at FreeBSD.org>
CommitDate: 2021-02-11 02:49:44 +0000
grep: fix null pattern and empty pattern file behavior
The null pattern semantics were terrible because I tried to match gnugrep,
but I got it wrong. Let's unwind that:
- The null pattern should match every line if neither -w nor -x.
- The null pattern should match empty lines if -x.
- The null pattern should not match any lines if -w.
The first two will stop processing (shortcut) even if additional patterns
are specified. In any other case, we will continue processing other
patterns. If no other patterns are specified beside a null pattern, then
we match if neither -w nor -x or set and do not match if either of those
are specified.
The justification for -w is that it should match on a whole word, but the
null pattern deos not have a whole word to match on.
Empty pattern files should never match anything, and more importantly, -v
should cause everything to be written.
PR: 253209
(cherry picked from commit f823c6dc730b0dd08b54a53be1d8fd587eee7021)
contrib/netbsd-tests/usr.bin/grep/t_grep.sh | 22 +++++++++++++++---
usr.bin/grep/grep.c | 11 ---------
usr.bin/grep/util.c | 35 +++++++++++++----------------
3 files changed, 35 insertions(+), 33 deletions(-)
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the freebsd-bugs
mailing list