On Friday 08 May 2009 16:59:19 Etaoin Shrdlu wrote:
> On Friday 8 May 2009, 16:10, Alan McKinnon wrote:
> > 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
>
> That will output an uncaptured error message if --color is not supported.

which is the desired effect. It causes the if to be false and the grep options 
are not enabled (as they are not supported)

-- 
alan dot mckinnon at gmail dot com

Reply via email to