Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] 'if echo hello' in .bashrc Christian <mcr76@×××.net>
Re: [gentoo-user] 'if echo hello' in .bashrc Etaoin Shrdlu <shrdlu@×××××××××××××.org>
Re: [gentoo-user] 'if echo hello' in .bashrc Eray Aslan <eray.aslan@×××××××.tr>
Re: [gentoo-user] 'if echo hello' in .bashrc Carlos Hendson <skyclan@×××.net>
Re: [gentoo-user] 'if echo hello' in .bashrc Mike Kazantsev <mike_kazantsev@×××××××.net>