GNU bug report logs - #19998
GREP_OPTIONS alternative?

Previous Next

Package: grep;

Reported by: Christian Kujau <lists <at> nerdbynature.de>

Date: Wed, 4 Mar 2015 07:09:02 UTC

Severity: normal

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

Bug is archived. No further changes may be made.

Full log


Message #34 received at 19998-done <at> debbugs.gnu.org (full text, mbox):

From: Christian Kujau <lists <at> nerdbynature.de>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 19998-done <at> debbugs.gnu.org
Subject: Re: bug#19998: GREP_OPTIONS alternative?
Date: Wed, 11 Mar 2015 15:53:35 -0700 (PDT)
On Wed, 11 Mar 2015 at 15:33, Paul Eggert wrote:
> > 1) Write a script for each grep variant (fgrep, zgrep, egrep, etc.)
> > 2) put $HOME/bin in $PATH
> 
> No, you don't need to write a script for each grep variant.  You need to write
> a script only for 'grep'.  That's because fgrep etc. invoke grep.

One might think so, but it doesn't work. On a Debian/Linux or a 
SuSE Linux system, /bin/*grep are not symlinks to /bin/grep but
seperate executables. Even zgrep (a shell script) rewrites itself
to /usr/bin/bin and thus $HOME/bin/grep is never called.

> It's too error-prone to have fundamental utilities' behavior depend on
> settings of random environment variables.

Why is GREP_OPTIONS random and LESS or ZIPOPT or GZIP are not?

Christian.


$ cat $HOME/bin/grep
#!/bin/sh
export PATH=/usr/bin:/bin
exec grep --line-number "$@"

$ unset GREP_OPTIONS
$ export PATH=$HOME/bin:$PATH

$ echo hello | grep ll
1:hello

$ echo hello | fgrep ll
hello
-- 
BOFH excuse #143:

had to use hammer to free stuck disk drive heads.




This bug report was last modified 10 years and 134 days ago.

Previous Next


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