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 |