Commit 4886b2ed authored by Dmitry Gutov's avatar Dmitry Gutov
Browse files

Use regexp matching instead of checking exit status

* lisp/progmodes/xref.el (xref-collect-matches):
See if the output buffer contents look like Grep output
instead of checking exit status (bug#23451).
parent 299a96c7
......@@ -935,11 +935,14 @@ IGNORES is a list of glob patterns."
(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))
;; Can't use the exit status: Grep exits with 1 to mean "no
;; matches found". Find exits with 1 if any of the invocations
;; exit with non-zero. "No matches" and "Grep program not found"
;; are all the same to it.
(when (and (/= (point-min) (point-max))
(not (looking-at grep-re)))
(user-error "Search failed with status %d: %s" status (buffer-string)))
(while (re-search-forward grep-re nil t)
(push (list (string-to-number (match-string 2))
(match-string 1)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment