emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 3bc3dc4: Signal error if find-grep returns a nonzer


From: Dmitry Gutov
Subject: [Emacs-diffs] master 3bc3dc4: Signal error if find-grep returns a nonzero status
Date: Sun, 28 May 2017 19:56:18 -0400 (EDT)

branch: master
commit 3bc3dc406343bd7e50acae7c0f9d5f8cc89420cd
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Signal error if find-grep returns a nonzero status
    
    * lisp/progmodes/xref.el (xref-collect-matches): Signal error
    if find-grep returns a nonzero status (bug#23451).  Remove the
    comment: even if some output is present, a non-zero status
    means something went wrong and it can't be relied upon.
---
 lisp/progmodes/xref.el | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 9b6a560..c43f3a4 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -929,14 +929,16 @@ IGNORES is a list of glob patterns."
                                        ignores))
          (buf (get-buffer-create " *xref-grep*"))
          (grep-re (caar grep-regexp-alist))
+         status
          hits)
     (with-current-buffer buf
       (erase-buffer)
-      (call-process-shell-command command nil t)
-      ;; FIXME: What to do when the call fails?
-      ;; "find: ‘xyzgrep’: No such file or directory\n"
-      ;; The problem is, find-grep can exit with a nonzero code even
-      ;; when there are some matches in the output.
+      (setq status
+            (call-process-shell-command command nil t))
+      (when (and (not (zerop status))
+                 ;; Nonzero status can mean "no matches found".
+                 (/= (point-min) (point-max)))
+        (user-error "Search failed with status %d: %s" status (buffer-string)))
       (goto-char (point-min))
       (while (re-search-forward grep-re nil t)
         (push (list (string-to-number (match-string 2))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]