unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#49978: 28.0.50; grep-highlight-matches auto-detection broken on macOS [PATCH]
@ 2021-08-10 12:54 Mattias Engdegård
  2021-08-10 13:23 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Mattias Engdegård @ 2021-08-10 12:54 UTC (permalink / raw)
  To: 49978

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

The auto-detection of colourised grep fails on macOS (and presumably BSD in general) because grep --help exits with a nonzero status (while still printing a useful option summary).

We should just ignore the exit status. Anyone against the attached patch?


[-- Attachment #2: grep-highlight-matches-autodetect.diff --]
[-- Type: application/octet-stream, Size: 896 bytes --]

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 8f0a5acf70..a33a247d9b 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -696,11 +696,11 @@ grep-compute-defaults
     (when (eq grep-highlight-matches 'auto-detect)
       (setq grep-highlight-matches
 	    (with-temp-buffer
-	      (and (grep-probe grep-program '(nil t nil "--help"))
-		   (progn
-		     (goto-char (point-min))
-		     (search-forward "--color" nil t))
-		   ;; Windows and DOS pipes fail `isatty' detection in Grep.
+              ;; The "grep --help" exit status varies; pay no attention to it.
+              (grep-probe grep-program '(nil t nil "--help"))
+	      (goto-char (point-min))
+	      (and (search-forward "--color" nil t)
+	           ;; Windows and DOS pipes fail `isatty' detection in Grep.
 		   (if (memq system-type '(windows-nt ms-dos))
 		       'always 'auto)))))
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-10 15:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-10 12:54 bug#49978: 28.0.50; grep-highlight-matches auto-detection broken on macOS [PATCH] Mattias Engdegård
2021-08-10 13:23 ` Eli Zaretskii
2021-08-10 13:39   ` Mattias Engdegård
2021-08-10 13:57     ` Eli Zaretskii
2021-08-10 14:03       ` Lars Ingebrigtsen
2021-08-10 15:11       ` Mattias Engdegård

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).