diff options
| author | Kyle Evans <kevans@FreeBSD.org> | 2021-02-04 21:35:58 +0000 |
|---|---|---|
| committer | Kyle Evans <kevans@FreeBSD.org> | 2021-02-11 02:49:55 +0000 |
| commit | bbce8cbba9116e5a5061e6e661bfa078ff0c783e (patch) | |
| tree | 5f7d73df6168ee6f3da7d3ce902dc6271d570a81 | |
| parent | 574d0dfae5011a766aa967f1d1675ddf7b535936 (diff) | |
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)
| -rw-r--r-- | usr.bin/grep/grep.1 | 5 | ||||
| -rw-r--r-- | usr.bin/grep/grep.c | 4 |
2 files changed, 8 insertions, 1 deletions
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(); |
