>From d3a7315d770897dfb3cd826f399d822b1b771d0b Mon Sep 17 00:00:00 2001 From: Paul Eggert
Date: Tue, 5 Nov 2019 15:32:58 -0800 Subject: [PATCH] grep: new --no-ignore-case option Suggested by Karl Berry and mostly implemented by Arnold Robbins (Bug#37907). * NEWS: * doc/grep.in.1: * doc/grep.texi (Matching Control): * src/grep.c (usage): Document the new option. * src/grep.c (NO_IGNORE_CASE_OPTION): New constant. (long_options, main): Support new option. --- NEWS | 5 +++++ doc/grep.in.1 | 9 ++++++++- doc/grep.texi | 7 +++++++ src/grep.c | 9 ++++++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 9ce65b3..c31c600 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ GNU grep NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** New features + + The new --no-ignore-case option causes grep to observe case + distinctions, overriding any previous -i (--ignore-case) option. + ** Bug fixes The exit status of 'grep -L' is no longer incorrect when standard diff --git a/doc/grep.in.1 b/doc/grep.in.1 index a2cbf5c..219f37f 100644 --- a/doc/grep.in.1 +++ b/doc/grep.in.1 @@ -254,6 +254,13 @@ Ignore case distinctions in patterns and input data, so that characters that differ only in case match each other. .TP +.B \-\^\-no\-ignore\-case +Do not ignore case distinctions in patterns and input data. +This is the default. +This option is useful for passing to shell scripts that already use +.BR \-i , +to cancel its effects because the two options override each other. +.TP .BR \-v ", " \-\^\-invert\-match Invert the sense of matching, to select non-matching lines. .TP @@ -683,7 +690,7 @@ Follow all symbolic links, unlike .BR \-r . .SS "Other Options" .TP -.BR \-\^\-line\-buffered +.B \-\^\-line\-buffered Use line buffering on output. This can cause a performance penalty. .TP diff --git a/doc/grep.texi b/doc/grep.texi index f5edc72..01ad5f7 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -215,6 +215,13 @@ SHARP S) even though lowercasing the latter yields the former. @option{-y} is an obsolete synonym that is provided for compatibility. (@option{-i} is specified by POSIX.) +@item --no-ignore-case +@opindex --no-ignore-case +Do not ignore case distinctions in patterns and input data. This is +the default. This option is useful for passing to shell scripts that +already use @option{-i}, in order to cancel its effects because the +two options override each other. + @item -v @itemx --invert-match @opindex -v diff --git a/src/grep.c b/src/grep.c index 7f3ada1..edf90ab 100644 --- a/src/grep.c +++ b/src/grep.c @@ -424,7 +424,8 @@ enum GROUP_SEPARATOR_OPTION, INCLUDE_OPTION, LINE_BUFFERED_OPTION, - LABEL_OPTION + LABEL_OPTION, + NO_IGNORE_CASE_OPTION }; /* Long options equivalences. */ @@ -455,6 +456,7 @@ static struct option const long_options[] = {"help", no_argument, &show_help, 1}, {"include", required_argument, NULL, INCLUDE_OPTION}, {"ignore-case", no_argument, NULL, 'i'}, + {"no-ignore-case", no_argument, NULL, NO_IGNORE_CASE_OPTION}, {"initial-tab", no_argument, NULL, 'T'}, {"label", required_argument, NULL, LABEL_OPTION}, {"line-buffered", no_argument, NULL, LINE_BUFFERED_OPTION}, @@ -1927,6 +1929,7 @@ Pattern selection and interpretation:\n"), getprogname ()); -e, --regexp=PATTERNS use PATTERNS for matching\n\ -f, --file=FILE take PATTERNS from FILE\n\ -i, --ignore-case ignore case distinctions in patterns and data\n\ + --no-ignore-case do not ignore case distinctions (default)\n\ -w, --word-regexp match only whole words\n\ -x, --line-regexp match only whole lines\n\ -z, --null-data a data line ends in 0 byte, not newline\n")); @@ -2617,6 +2620,10 @@ main (int argc, char **argv) match_icase = true; break; + case NO_IGNORE_CASE_OPTION: + match_icase = false; + break; + case 'L': /* Like -l, except list files that don't contain matches. Inspired by the same option in Hume's gre. */ -- 2.23.0