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.