Subject: bug#19998: closed (Re: bug#19998: GREP_OPTIONS alternative?)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 11 Mar 2015 18:17:02 +0000

Your bug report

#19998: GREP_OPTIONS alternative?

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].

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

Subject: Re: bug#19998: GREP_OPTIONS alternative?
From: Paul Eggert <[email-masked]>
To: Christian Kujau <[email-masked]>
Cc: [email-masked]
Date: Wed, 11 Mar 2015 11:15:59 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

On 03/05/2015 11:24 AM, Christian Kujau wrote:
> that (and the bits below) seem to confirm that there's no simple
> alternative to GREP_OPTIONS

I don't see why the script solution is not considered 'simple'. Anyway, 
it's worth documenting the script alternative, so I installed the 
attached into the manual and am marking the bug as done.
>From cd5e8b1071296d930a88d60789f24abab941b81a Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Wed, 11 Mar 2015 11:14:51 -0700
Subject: [PATCH] doc: give a script wrapper example

* doc/grep.texi (Environment Variables): Give an example of a
wrapper script, as an alternative to using GREP_OPTIONS.
Fixes: bug#19998
---
 doc/grep.texi | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/doc/grep.texi b/doc/grep.texi
index 18a1102..e3495bb 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -838,6 +838,15 @@ explicit options.
 As this causes problems when writing portable scripts, this feature
 will be removed in a future release of @command{grep}, and @command{grep}
 warns if it is used.  Please use an alias or script instead.
+For example, if @command{grep} is in the directory @samp{/usr/bin} you
+can prepend @file{$HOME/bin} to your @env{PATH} and create an
+executable script @file{$HOME/bin/grep} containing the following:
+
+@example
+#! /bin/sh
+export PATH=/usr/bin
+exec grep --color=auto --devices=skip "$@@"
+@end example
 
 @item GREP_COLOR
 @vindex GREP_COLOR @r{environment variable}
-- 
2.1.0

Subject: GREP_OPTIONS alternative?
From: Christian Kujau <[email-masked]>
To: [email-masked]
Date: Tue, 3 Mar 2015 21:55:18 -0800 (PST)
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

much to my dismay I noticed that GREP_OPTIONS has been made obsolete. I 
usually kept the following in my .profile:

  export GREP_OPTIONS='--color=tty --devices=skip'

which was honored by GNU/grep and BSD/grep and ignored by e.g 
SUNWcsu/grep. Without GREP_OPTIONS, I have to put something like this in 
my .profile:

if grep --version 2>/dev/null | egrep -q 'GNU|BSD' 2>/dev/null; then
        alias   grep='grep   --color=auto --devices=skip'
fi

But that leaves out all the other grep variants, so what I really have in 
my .profile now is something like this:

if grep --version 2>/dev/null | egrep -q 'GNU|BSD' 2>/dev/null; then
        alias   grep='grep   --color=auto --devices=skip'
        alias  egrep='egrep  --color=auto --devices=skip'
        alias  fgrep='fgrep  --color=auto --devices=skip'
        alias  zgrep='zgrep  --color=auto --devices=skip'
        alias bzgrep='bzgrep --color=auto --devices=skip'
        alias xzgrep='xzgrep --color=auto --devices=skip'
fi

(and even that leaves out bzegrep, xzfgrep, etc.)

I suspect that I'm doing it wrong - but what's the alternative to have 
some nice grep defaults and still be portable across platforms?

Thanks,
Christian.
-- 
BOFH excuse #355:

Boredom in the Kernel.