patchgrep - Patches: patch #5353, Quick patch to colorize grep's own...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #5353: Quick patch to colorize grep's own printout (filename, line number and byte marker)

Submitter:  None
Submitted:  Thu 31 Aug 2006 12:28:07 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Invalid Privacy:  Public
Assigned to:  None Originator Email:  -email is unavailable-
Open/Closed:  Closed

Thu 14 Jul 2011 09:12:44 AM UTC, comment #1: 

The functionality is already present in more recent grep versions (starting at 2.5.2, mysteriously absent from the NEWS file??) using the GREP_COLORS environment variable.

Paolo Bonzini <bonzini>
Thu 31 Aug 2006 12:28:07 AM UTC, original submission:  

--- grep-2.5.1a/src/grep.c 2004-11-12 13:25:35.000000000 +0200
+++ grep-2.5.1a-new/src/grep.c 2006-08-31 03:19:22.000000000 +0300
@@ -76,6 +76,9 @@
    variable GREP_COLOR.  The default is to print red.  */
 static const char *grep_color = "01;31";
 
+/* The filename color string. The default is to print dark green.  */
+static const char *grep_color2 = "0;32";
+
 static struct exclude *excluded_patterns;
 static struct exclude *included_patterns;
 /* Short options.  */
@@ -512,6 +515,8 @@
 static void
 prline (char const *beg, char const *lim, int sep)
 {
+  if (color_option && (out_file || out_line || out_byte))
+    printf("\33[%sm", grep_color2);
   if (out_file)
     printf ("%s%c", filename, sep & filename_mask);
   if (out_line)
@@ -529,6 +534,8 @@
 #endif
       print_offset_sep (pos, sep);
     }
+  if (color_option && (out_file || out_line || out_byte))
+    fputs("\33[00m", stdout);
   if (only_matching)
     {
       size_t match_size;

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bonzini (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-07-14 bonzini Open/ClosedOpen Closed
    2011-07-14 bonzini StatusNone Invalid
    2006-08-31 None Carbon-Copy- Added -unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code