all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: 9226@debbugs.gnu.org
Subject: bug#9226: 23.3; [rgrep]; (matches found) ?
Date: Sat, 17 Sep 2011 21:24:16 +0300	[thread overview]
Message-ID: <87obyjauy7.fsf@mail.jurta.org> (raw)
In-Reply-To: <87y5yskmku.fsf@mail.jurta.org> (Juri Linkov's message of "Wed, 17 Aug 2011 19:50:00 +0300")

> 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)))





      parent reply	other threads:[~2011-09-17 18:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-03  1:40 bug#9226: 23.3; [rgrep]; (matches found) ? Dave Abrahams
2011-08-10  7:16 ` Glenn Morris
2011-08-10 13:35   ` Stefan Monnier
2011-08-10 15:10     ` Juri Linkov
2011-08-17 14:52       ` Dave Abrahams
2011-08-17 15:02         ` Lennart Borgman
2011-08-17 16:50         ` Juri Linkov
2011-08-22  9:54           ` Juri Linkov
2011-09-17 18:24           ` Juri Linkov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87obyjauy7.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=9226@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.