Subject: bug#37907: closed (Re: bug#37907: --no-ignore-case option)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 05 Nov 2019 23:39:04 +0000

Your bug report

#37907: --no-ignore-case option

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
37907: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=37907
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#37907: --no-ignore-case option
From: Paul Eggert <[email-masked]>
To: [email-masked]
Cc: [email-masked], [email-masked]
Date: Tue, 5 Nov 2019 15:38:12 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

On 10/24/19 1:40 PM, [email-masked] wrote:

> I chose '-g' since that letter was unused. It has no mnemonic value.

Thanks for implementing that. Other grep-like programs tend to use -I 
for this option, since it negates -i. Obviously we can't do that right 
now since -I means --binary-files=without-match to GNU grep. So I 
installed the attached, which takes the more-conservative approach of 
implementing just --no-ignore-case without any single-letter option. 
Perhaps in the future we could deprecate -I and then eventually 
repurpose it? But in the meantime this particular feature request is 
done, so I'm taking the liberty of closing the bug report.
>From d3a7315d770897dfb3cd826f399d822b1b771d0b Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
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

Subject: --no-ignore-case option
From: Karl Berry <[email-masked]>
To: [email-masked]
Date: Thu, 24 Oct 2019 12:26:10 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

I suggest adding --no-ignore-case to clear the case-insensitivity -i
search. I, and surely many others, have an alias or script that runs
grep with -i by default, along with other options (since GREP_OPTIONS
was killed). It would be highly convenient to be able to add
--no-ignore-case on the fly to the rare-in-my-experience invocations
where case sensitivity is desired.

(Also, just in principle, it seems like any boolean option should be
switchable by successive options. But I won't go that far.)

Besides, since I'm not sending a patch (sorry), my expectation is that
there will never be enough time to implement random minor suggestions
like this, so it doesn't matter :).

Thanks,
Karl