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. |