Gentoo Archives: gentoo-user

From: Etaoin Shrdlu <shrdlu@×××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] 'if echo hello' in .bashrc
Date: Fri, 08 May 2009 14:47:05
Message-Id: 200905081659.19936.shrdlu@unlimitedmail.org
In Reply to: Re: [gentoo-user] 'if echo hello' in .bashrc by Alan McKinnon
1 On Friday 8 May 2009, 16:10, Alan McKinnon wrote:
2 > On Friday 08 May 2009 16:01:14 Mike Kazantsev wrote:
3 > > On Fri, 8 May 2009 14:38:58 +0100
4 > >
5 > > Stroller <stroller@××××××××××××××××××.uk> wrote:
6 > > > To find the part to which I refer you'll need to scroll down about
7 > > > halfway through that page to "Colorize grep"; the author advises
8 > > > adding:
9 > > >
10 > > > if echo hello|grep --color=auto l >/dev/null 2>&1; then
11 > > > export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
12 > > > fi
13 > > >
14 > > > to ~/.bashrc
15 > > >
16 > > > Why does he echo hello, please?
17 > >
18 > > Some greps (like BSD one) might not support '--color' option, so
19 > > "echo hello|grep --color=auto l" will return error code, skipping if
20 > > clause, and won't break grep operation by adding an unsupported
21 > > option.
22 >
23 > except that STDERR is combined with STDOUT and sent to /dev/null so
24 > the script will never get it, the if is always true and the entire
25 > check is redundant. Better would be
26 >
27 > if echo hello|grep --color=auto l >/dev/null ; then
28
29 That will output an uncaptured error message if --color is not supported.

Replies

Subject Author
Re: [gentoo-user] 'if echo hello' in .bashrc Alan McKinnon <alan.mckinnon@×××××.com>