Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 05 Feb 2021 03:00:49 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 253209] grep -v -f some-empty-file -- does the wrong thing
Message-ID:  <bug-253209-227-0aKJGVnnwX@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-253209-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-253209-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D253209

--- Comment #2 from commit-hook@FreeBSD.org ---
A commit in branch main references this bug:

URL:
https://cgit.FreeBSD.org/src/commit/?id=3Df823c6dc730b0dd08b54a53be1d8fd587=
eee7021

commit f823c6dc730b0dd08b54a53be1d8fd587eee7021
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2021-02-04 21:26:45 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2021-02-05 02:59:42 +0000

    grep: fix null pattern and empty pattern file behavior

    The null pattern semantics were terrible because I tried to match gnugr=
ep,
    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 patter=
ns
    are specified. In any other case, we will continue processing other
    patterns.  If no other patterns are specified beside a null pattern, th=
en
    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 t=
he
    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
    MFC-after:      4 days

 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(-)

--=20
You are receiving this mail because:
You are on the CC list for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-253209-227-0aKJGVnnwX>