Eleven years since the bug was filled, I'm working to close this bug,
but better late than never.

I've slightly modified your patch to match the current files in grep
structure. Please tell me if this would be correct:

--- a/src/main.c    2011-06-01 18:55:32.000000000 +0200
+++ b/src/main.c    2011-06-01 19:12:03.000000000 +0200
@@ -1267,7 +1267,7 @@
     status = count + 2;
   else
     {
-      if (count_matches)
+      if (count_matches && (count || (count_matches == 1)))
         {
           if (out_file)
             {
@@ -2088,14 +2088,23 @@
       }
 
   /* POSIX.2 says that -q overrides -l, which in turn overrides the
-     other output options.  */
+     other output options.  We violate this slightly by allowing -c
+     and -l to coexist (print 'file:count' but skip if count==0).  */
   if (exit_on_match)
-    list_files = 0;
-  if (exit_on_match | list_files)
     {
+      list_files = 0;
       count_matches = 0;
       done_on_match = 1;
     }
+  else if (list_files && count_matches)
+    {
+      list_files = 0;
+      count_matches = 2;
+      done_on_match = 0;
+    }
+  else if (list_files)
+    done_on_match = 1;
+
   out_quiet = count_matches | done_on_match;
 
   if (out_after < 0)

I've put the patch in debian's git repository in collab-maint
git://git.debian.org/git/collab-maint/grep.git , and upload a test
package to http://people.debian.org/~santiago/grep/  Could you please
try it out?

Thanks a lot, and really sorry for not taking care of this bug before,

Santiago





-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to