git: 1db55207b661 - stable/12 - grep: turn off -w if -x is specified
Kyle Evans
kevans at FreeBSD.org
Thu Feb 11 15:21:09 UTC 2021
The branch stable/12 has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=1db55207b66154de839e515046736cd06e50fe30
commit 1db55207b66154de839e515046736cd06e50fe30
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-11 15:20:18 +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 b6f6e6f31d22..9aac1cc6ca92 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 August 7, 2020
+.Dd February 11, 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 cc860b0566d4..a9c67c268b47 100644
--- a/usr.bin/grep/grep.c
+++ b/usr.bin/grep/grep.c
@@ -635,6 +635,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-all
mailing list