GNU bug report logs - #9226
23.3; [rgrep]; (matches found) ?

Previous Next

Package: emacs;

Reported by: Dave Abrahams <dave <at> boostpro.com>

Date: Wed, 3 Aug 2011 01:42:02 UTC

Severity: normal

Found in version 23.3

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

Full log


Message #23 received at 9226 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dave Abrahams <dave <at> boostpro.com>
Cc: Glenn Morris <rgm <at> gnu.org>, 9226 <at> debbugs.gnu.org,
	Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9226: 23.3; [rgrep]; (matches found) ?
Date: Wed, 17 Aug 2011 19:50:00 +0300
> Sounds like an improvement to me.

This patch below fixes the case you reported and also the case of
"find | xargs grep" because it checks the value of buffer-modified
set in `compilation-start', whereas empty output doesn't change it.
It still relies on unreliable heuristics, but I carefully tested it with
all known test cases and it displays correct messages in all of them.
Running grep on the dir with a file containing "test", I get the following
results (command and exit status message):

grep -inH -e "test" *
Grep finished (matches found)

grep -inH -e "testx" *
Grep finished with no matches found

grepx -inH -e "test" *
Grep exited abnormally with code 127

find . -exec grep -i test {} \;
Grep finished (matches found)

find . -exec grep -i testx {} \;
Grep finished with no matches found

find . -name testx -exec grep -i testx {} \;
Grep finished with no matches found

find . -print0 | xargs -0 -e grep -i -nH -e test
Grep finished (matches found)

find . -print0 | xargs -0 -e grep -i -nH -e testx
Grep finished with no matches found

=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el	2011-08-10 20:31:17 +0000
+++ lisp/progmodes/grep.el	2011-08-17 16:47:24 +0000
@@ -463,9 +463,9 @@ (defun grep-process-setup ()
   (set (make-local-variable 'compilation-exit-message-function)
        (lambda (status code msg)
 	 (if (eq status 'exit)
-	     (cond ((zerop code)
+	     (cond ((and (zerop code) (buffer-modified-p))
 		    '("finished (matches found)\n" . "matched"))
-		   ((= code 1)
+		   ((or (= code 1) (not (buffer-modified-p)))
 		    '("finished with no matches found\n" . "no match"))
 		   (t
 		    (cons msg code)))





This bug report was last modified 13 years and 307 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.