Subject: Re: bug#19998: GREP_OPTIONS alternative?

From: Norihiro Tanaka <[email-masked]>
Date: Fri, 06 Mar 2015 00:29:25 +0900

On Wed, 4 Mar 2015 17:04:06 -0800 (PST)
Christian Kujau <[email-masked]> wrote:

> On Wed, 4 Mar 2015 at 14:43, Paul Eggert wrote:
> > You can put a script like this in $HOME/bin:
> > 
> > #! /bin/sh
> > export PATH=/usr/bin
> > exec grep --color=auto --devices=skip "$@"
> > 
> > and then prepend $HOME/bin to your PATH.
> 
> Well, and I'd have to do this for every *grep variant, so instead of 
> creating different aliases, I'm creating different scripts, which is an 
> even greater change :-(
> 
> Is there really no other way?
> 
> I hope nobody removes PAGER, LESS or HISTCONTROL anytime soon :-\
> 
> Christian.
> -- 
> BOFH excuse #88:
> 
> Boss' kid fucked up the machine
> 
> 

Please think to use grep -F and grep -E instead of fgrep and egrep.
For others, you can use following script, or customize grep's source
code and rebuild it to change default.

--
mv /bin/grep /bin/grep.bin
cat <<EOF >/bin/grep
#! /bin/sh
exec /bin/grep.bin --color=auto --devices=skip "$@"
EOF
chmod a+x /bin/grep
--

--
diff -ru grep-2.21.orig/src/grep.c grep-2.21/src/grep.c
--- grep-2.21.orig/src/grep.c   2014-11-09 19:00:37.000000000 +0000
+++ grep-2.21/src/grep.c        2015-03-05 15:26:59.000000000 +0000
@@ -72,7 +72,7 @@
 static bool suppress_errors;

 /* If nonzero, use color markers.  */
-static int color_option;
+static int color_option = 2;

 /* Show only the part of a line matching the expression. */
 static bool only_matching;
@@ -391,7 +391,7 @@
     READ_COMMAND_LINE_DEVICES,
     READ_DEVICES,
     SKIP_DEVICES
-  } devices = READ_COMMAND_LINE_DEVICES;
+  } devices = SKIP_DEVICES;

 static bool grepfile (int, char const *, bool, bool);
 static bool grepdesc (int, bool);
--