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