On Friday 08 May 2009 16:01:14 Mike Kazantsev wrote:
> On Fri, 8 May 2009 14:38:58 +0100
>
> Stroller <strol...@stellar.eclipse.co.uk> wrote:
> > To find the part to which I refer you'll need to scroll down about
> > halfway through that page to "Colorize grep"; the author advises adding:
> >
> >    if echo hello|grep --color=auto l >/dev/null 2>&1; then
> >      export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
> >    fi
> >
> > to ~/.bashrc
> >
> > Why does he echo hello, please?
>
> Some greps (like BSD one) might not support '--color' option, so "echo
> hello|grep --color=auto l" will return error code, skipping if clause,
> and won't break grep operation by adding an unsupported option.

except that STDERR is combined with STDOUT and sent to /dev/null so the script 
will never get it, the if is always true and the entire check is redundant. 
Better would be

if echo hello|grep --color=auto l >/dev/null ; then

-- 
alan dot mckinnon at gmail dot com

Reply via email to