[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grep patch: color support
From: |
Eric Agnew |
Subject: |
Re: grep patch: color support |
Date: |
Tue, 20 Mar 2001 17:38:17 -0800 |
User-agent: |
Mutt/1.3.15i |
On Mar 09, 2001, Alan Magloire wrote:
> Eric Agnew wrote:
>> I've been playing w/ ANSI color codes way too much lately, & decided
>> that grep should have a --color option like ls does... so I looked at
>> the code & hacked it around until it worked. Haven't quite been able
>> to generate a working 'grepcolors' yet, though, as I didn't want to
>> move -everything- from the fileutils package over...
>>
>> So, yeah- I've attached a patch that'll get grep color-enabled. I'm
>> sure it could stand a bit of cleaning up, and it might be desirable to
>> wrap all the color stuff in an #ifdef for people who want to compile
>> without it, etc.. but this should be a good start. :)
> If you resubmit your patch and isolate all the color dependencies into
> another file it might stand a good chance for inclusion. You should Cc:
> you patch to address@hidden, it's not because I did not have time
> to go through it thoroughly that others may not find it very useful.
Hello again.. I just found the new grep 2.5e w/ minimal color support-
actually, it was the only part of what I was trying to do that I hadn't
figured out yet (highlighting the actual pattern in the match)! So, I've
applied my original changes to the new file, which means it's even better:
- supports GNU color-ls-type auto/always/never argument to '--color'
option ('auto' checks isatty, so it won't screw up pipes)
- supports GREP_COLORS env variable (works just like LS_COLORS, as it's
from the same exact code) to specify colors for all options
- can color filename, line number, byte, context lines, & count (and can
do different colors for count of 0), as well as the actual pattern
I tried taking your suggestion & splitting most of the code into a
separate file, but my knowledge of C & Makefiles is quite limited & I
couldn't get it to work.. but since you now have some of the color stuff
built right into grep.c this shouldn't be too much of a bother. :) Perhaps
someone more knowledgeable would {rather|be able to} split off the
parse_grep_color, get_funky_string, etc. functions into a separate file
(although they didn't seem to mind having them in ls.c). But most of the
stuff is in big blocks (aside from the scattered print_color_indicator
calls), so it shouldn't be too confusing.. especially for anyone familiar
w/ the ls code. :)
Anyway, I'll Cc: to bug-gnu-utils as suggested, & hope this is useful &
that someone else more knowledgeable can run with it. Now that the other
color stuff is in there, hopefully the rest will make it in as well.
--
Eric Agnew agnew at geekhive dot net
grep25e-color-patch.diff
Description: Text document
- Re: grep patch: color support,
Eric Agnew <=