GNU bug report logs - #26205
Unhappy with deprecating GREP_OPTIONS

Previous Next

Package: grep;

Reported by: Thomas Güttler <guettliml <at> thomas-guettler.de>

Date: Tue, 21 Mar 2017 15:40:01 UTC

Severity: normal

Tags: wontfix

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 26205 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Thomas Güttler <guettliml <at> thomas-guettler.de>,
 26205 <at> debbugs.gnu.org
Subject: Re: bug#26205: Unhappy with deprecating GREP_OPTIONS
Date: Tue, 21 Mar 2017 11:05:21 -0500
[Message part 1 (text/plain, inline)]
On 03/21/2017 10:39 AM, Thomas Güttler wrote:

> 
>  * Strategy 1: GREP_OPTIONS. But this is deprecated. See
> http://www.gnu.org/software/grep/manual/html_node/Environment-Variables.html
> 
>  * Stragegy 2: GREP_COLORS look like a solution at the first sight, but
> this does something different.
>  * Strategy 3: alias. This does not work for `find ... | xargs grep`,
> since xargs does not evaluate aliases.

It can if you teach it to (assuming you are using a sh-like shell):

alias xargs='xargs '

(I can't help you if you are using a csh-like shell)

>  * Strategy 4: Write a simple wrapper script. No, I think this is too
> dirty and makes more trouble than it solves.

What trouble does it cause? This our preferred recommendation, by the way.

>  * Strategy 5: patch the source code  - No

Why not? It's open source, so you are free to do so, for your local setup.

>  * Strategy 6: Contact grep developers, ask for a replacement of
> GREP_OPTIONS

Which you've done. But it won't help, because we made a conscious
decision to kill environment variables that have the chance of breaking
scripts, and we are unlikely to be persuaded to change our minds.


> Why is GREP_OPTIONS deprecated?

Because it has the tendency to break unsuspecting scripts that don't
sanitize GREP_OPTIONS out of their environment.  Environment variables
that change default output are very dangerous.  Environment variables
that only modify behavior that has to be opted into (like GREP_COLORS)
are not as bad, but once you are explicitly opting into something, a
wrapper script is a lot more direct than a wrapper script + an
environment variable.

> 
> I guess this can do confusing things if you exclude directories via this
> environment variable.

Yes, that was one of the things known to break scripts.

> 
> But setting color=auto looks like something which does not do harm.

You're right that 'color=auto' tends to not break scripts, but
'color=always' does, and it gets rather hard, rather fast, if you try to
special-case WHICH aspects of GREP_OPTIONS are safe, vs. just a blanket
statement that GREP_OPTIONS is in general unsafe.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 2 years and 320 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.