On 8 May 2009, at 14:38, Stroller wrote:
...
 if echo hello|grep --color=auto l >/dev/null 2>&1; then
   export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
 fi

I'm afraid this thread has run away from me. I'm drinking the day's first cup of tea & rubbing my eyes furiously in confusion. Wha?
I'm sure I'll comprehend the discussion better when I re-read later.
However, is there actually any need to parse whether the grep supports colour before setting it?

Let's say we use BSD grep or Schilling grep or whatever - is there actually any harm in exporting GREP_OPTIONS='--color=auto' in this case?

Having written the above (so I might as well now send this message) it occurred to me to test it:

$ GREP_OPTIONS='--not-suported'
$ grep -i rabbit Alice\ in\ Wonderland.txt
grep: unrecognized option '--not-suported'
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
$

Presumably BSD grep & all other greps also support the GREP_OPTIONS environment variable?

Stroller


Reply via email to