1 |
On 17/06/06, Etaoin Shrdlu <shrdlu@×××××××××××××.org> wrote: |
2 |
> On Saturday 17 June 2006 12:15, Mick wrote: |
3 |
> |
4 |
> > I am getting confused here: why is module building related to setting |
5 |
> > grep's colour option? |
6 |
> |
7 |
> There is probably some script that parses the output of grep, and, |
8 |
> with --color=always, this includes terminal control characters and |
9 |
> escape sequences which confuse the parser. Using --color=auto, on the |
10 |
> other hand, is the correct way to do the "right" thing, ie grep |
11 |
> itself "knows" whether it should emit escape sequences to colorize the |
12 |
> output (if it's really outputting to terminal) or not (if, for example, |
13 |
> it's called from inside a command substitution). |
14 |
> |
15 |
> The following works: |
16 |
> echo "hello" | grep ello | grep hello |
17 |
> |
18 |
> |
19 |
> The following does not work, since the output of the first grep |
20 |
> contains "garbage" (from the point of view of the second grep) between |
21 |
> the "h" and the "e": |
22 |
> |
23 |
> echo "hello" | grep --color=always ello | grep hello # does not work |
24 |
> |
25 |
> |
26 |
> Finally, the next one works, because the first grep knows that colorizing |
27 |
> the output here is useless and does not emit escape sequences: |
28 |
> |
29 |
> echo "hello" | grep --color=auto ello | grep hello # works |
30 |
|
31 |
Thanks! Nice explanation. |
32 |
-- |
33 |
Regards, |
34 |
Mick |
35 |
-- |
36 |
gentoo-user@g.o mailing list |