On Saturday 9 May 2009, 12:15, Stroller wrote: > 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?
Yes, because if the grep implementation in question supports GREP_OPTIONS but doesn't support --color, you'll get errors when it's run. (The assumption the author made is that if --color is supported, then GREP_OPTIONS is too, which is reasonable and is what happens for GNU grep, although I cannot speak for other implementations).