Date: Thu, 11 Feb 2021 02:50:33 GMT From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: bbce8cbba911 - stable/13 - grep: turn off -w if -x is specified Message-ID: <202102110250.11B2oXHx023351@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=bbce8cbba9116e5a5061e6e661bfa078ff0c783e commit bbce8cbba9116e5a5061e6e661bfa078ff0c783e Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2021-02-04 21:35:58 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2021-02-11 02:49:55 +0000 grep: turn off -w if -x is specified -x overcomes -w in gnugrep, and it should here as well. Flip it off as needed to avoid confusing other parts of grep. (cherry picked from commit 2373acbbb77d694b997d90f3251810c6edf5d6d8) --- usr.bin/grep/grep.1 | 5 ++++- usr.bin/grep/grep.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/usr.bin/grep/grep.1 b/usr.bin/grep/grep.1 index d3b30828c821..338af7e6d454 100644 --- a/usr.bin/grep/grep.1 +++ b/usr.bin/grep/grep.1 @@ -30,7 +30,7 @@ .\" .\" @(#)grep.1 8.3 (Berkeley) 4/18/94 .\" -.Dd November 19, 2020 +.Dd February 4, 2021 .Dt GREP 1 .Os .Sh NAME @@ -405,6 +405,9 @@ and .Sq [[:>:]] ; see .Xr re_format 7 ) . +This option has no effect if +.Fl x +is also specified. .It Fl x , Fl Fl line-regexp Only input lines selected against an entire fixed string or regular expression are considered to be matching lines. diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index 33541e4fe734..166d3451774a 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -630,6 +630,10 @@ main(int argc, char *argv[]) aargc -= optind; aargv += optind; + /* xflag takes precedence, don't confuse the matching bits. */ + if (wflag && xflag) + wflag = false; + /* Fail if we don't have any pattern */ if (aargc == 0 && needpattern) usage();
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102110250.11B2oXHx023351>