[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19998: GREP_OPTIONS alternative?
From: |
Christian Kujau |
Subject: |
bug#19998: GREP_OPTIONS alternative? |
Date: |
Wed, 11 Mar 2015 15:53:35 -0700 (PDT) |
User-agent: |
Alpine 2.19.4 (DEB 40 2013-11-18) |
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.
- bug#19998: GREP_OPTIONS alternative?, Christian Kujau, 2015/03/04
- bug#19998: GREP_OPTIONS alternative?, Paul Eggert, 2015/03/04
- bug#19998: GREP_OPTIONS alternative?, Christian Kujau, 2015/03/04
- bug#19998: GREP_OPTIONS alternative?, Paul Eggert, 2015/03/04
- bug#19998: GREP_OPTIONS alternative?, Norihiro Tanaka, 2015/03/05
- bug#19998: GREP_OPTIONS alternative?, Christian Kujau, 2015/03/05
- bug#19998: GREP_OPTIONS alternative?, Paul Eggert, 2015/03/11
- bug#19998: GREP_OPTIONS alternative?, Christian Kujau, 2015/03/11
- bug#19998: GREP_OPTIONS alternative?, Paul Eggert, 2015/03/11
- bug#19998: GREP_OPTIONS alternative?,
Christian Kujau <=
- bug#19998: GREP_OPTIONS alternative?, Paul Eggert, 2015/03/11
- bug#19998: GREP_OPTIONS alternative?, Santiago Ruano Rincón, 2015/03/12
- bug#19998: GREP_OPTIONS alternative?, Christian Kujau, 2015/03/13
- bug#19998: GREP_OPTIONS alternative?, Paul Eggert, 2015/03/13
- bug#19998: GREP_OPTIONS alternative?, Christian Kujau, 2015/03/14