git: 2373acbbb77d - main - grep: turn off -w if -x is specified
Kyle Evans
kevans at FreeBSD.org
Fri Feb 5 02:59:59 UTC 2021
The branch main has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=2373acbbb77d694b997d90f3251810c6edf5d6d8
commit 2373acbbb77d694b997d90f3251810c6edf5d6d8
Author: Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2021-02-04 21:35:58 +0000
Commit: Kyle Evans <kevans at FreeBSD.org>
CommitDate: 2021-02-05 02:59:43 +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.
---
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();
More information about the dev-commits-src-main
mailing list