GNU bug report logs -
#9226
23.3; [rgrep]; (matches found) ?
Previous Next
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
View this message in rfc822 format
> 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)))
Another use-case:
find . -exec zgrep -inH test {} \;
./file1:1:Test #1
Grep finished (matches found)
find . -exec zgrep -inH test {} +
./file1:1:Test #1
Grep finished with no matches found
The latter's message is wrong because zgrep returns 1
when matches are found successfully.
The following patch provides more reliable message
"Grep exited abnormally with code 1" and still works
correctly for other cases:
--- lisp/progmodes/grep.el 2011-09-08 21:04:30 +0000
+++ lisp/progmodes/grep.el 2011-09-17 18:20:31 +0000
@@ -478,7 +478,7 @@ (defun grep-process-setup ()
;; so the buffer is still unmodified if there is no output.
(cond ((and (zerop code) (buffer-modified-p))
'("finished (matches found)\n" . "matched"))
- ((or (= code 1) (not (buffer-modified-p)))
+ ((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.