David Harrigan | 18 Jan 14:30
Picon
Gravatar

Fix for colo(u)r greps

Hi,

As something I like to do, I colourise my greps so that I can easily
see where the pattern matches. Now, I downloaded jtreg to try running
tests against the source code and I noticed that it was failing to
run, saying that I had to use a jdk version greater than 5. Strange I
thought, since I'm running JDK 6...anyway, to cut a long story short,
line 89 in bin/linux/jtreg is grep'ing for the version. Since I
include colour, control characters were being put in there. A simple
fix is to change the line to read

grep --color="never" "java version".....

Which tells grep not to colourise the searching, making jtreg work
wonderfully again.

Is this okay to go in as a patch? I'm happy to submit a patch file if required.

-=david=-

--

-- 
PGP Key Id: E2BE72FC
Public Key: http://www.harrigan.info/public.asc

Jonathan Gibbons | 18 Jan 20:14
Picon

Re: Fix for colo(u)r greps

David,

Thank you for your question.

--color is not supported on all versions of grep, so it would be 
inappropriate to always include the --color option. 

The two solutions that come to mind are to use a user environment 
variable, e.g. JTREG_GREP_OPTS, or to make the grep pattern more 
sensitive, perhaps by detecting the legal characters that can appear 
before or after the version number.

-- Jon

P.S. It seems strange that grep would generate colored output when the 
output is not a terminal.

David Harrigan wrote:
> Hi,
>
> As something I like to do, I colourise my greps so that I can easily
> see where the pattern matches. Now, I downloaded jtreg to try running
> tests against the source code and I noticed that it was failing to
> run, saying that I had to use a jdk version greater than 5. Strange I
> thought, since I'm running JDK 6...anyway, to cut a long story short,
> line 89 in bin/linux/jtreg is grep'ing for the version. Since I
> include colour, control characters were being put in there. A simple
> fix is to change the line to read
>
> grep --color="never" "java version".....
(Continue reading)


Gmane