From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#49978: 28.0.50; grep-highlight-matches auto-detection broken on macOS [PATCH] Date: Tue, 10 Aug 2021 14:54:43 +0200 Message-ID: <6D6B9A78-50EC-4AEC-80AA-EB12C608EB48@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_B99AD926-A9B5-4046-8AED-4A6B574B9BCD" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11953"; mail-complaints-to="usenet@ciao.gmane.io" To: 49978@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 10 14:56:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDRIg-0002rh-Me for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Aug 2021 14:56:10 +0200 Original-Received: from localhost ([::1]:47804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDRIe-0007JI-MH for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Aug 2021 08:56:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDRIY-0007Id-Eu for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 08:56:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDRIY-0003iA-8B for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 08:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDRIY-0005f3-6G for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 08:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Aug 2021 12:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49978 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162860010921694 (code B ref -1); Tue, 10 Aug 2021 12:56:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Aug 2021 12:55:09 +0000 Original-Received: from localhost ([127.0.0.1]:58683 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDRHh-0005dp-Bb for submit@debbugs.gnu.org; Tue, 10 Aug 2021 08:55:09 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:34436) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDRHe-0005dg-9b for submit@debbugs.gnu.org; Tue, 10 Aug 2021 08:55:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDRHd-0006ac-ME for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 08:55:06 -0400 Original-Received: from mail1444c50.megamailservers.eu ([91.136.14.44]:48924 helo=mail264c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDRHa-0002um-V7 for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 08:55:05 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1628600086; bh=Xqjzt2q/FE4X16V3bEOdYDSK48TqB6msytT6nK+FWGg=; h=From:Subject:Date:To:From; b=b8fbdWVsMwapgiwkuQ0W4PdT4L8hiI4y75/Zu5hdj1vuHX0ShlxX8EbpoqFOJDlSw AqX9PlCNiIbHG25qtEg+s2WT9d9CSyev1c7xEjAo4Sjn99xPVTYuoYYnikycLW2nXD Hg8ZG7Ne7LuYg/HG26cimNATjFEQcDrSVZ22cjjA= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.tele2.se [188.150.171.71]) (authenticated bits=0) by mail264c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 17ACsiI6007684 for ; Tue, 10 Aug 2021 12:54:46 +0000 X-Mailer: Apple Mail (2.3445.104.21) X-CTCH-RefID: str=0001.0A742F16.61127716.0023, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=Xdb3M7x5 c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=-McoaDol7z_dJMetT8AA:9 a=CjuIK1q_8ugA:10 a=jTK3ahojEUwcQVQlomkA:9 a=De_Ol2h6w80A:10 X-Origin-Country: SE Received-SPF: softfail client-ip=91.136.14.44; envelope-from=mattiase@acm.org; helo=mail264c50.megamailservers.eu X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:211485 Archived-At: --Apple-Mail=_B99AD926-A9B5-4046-8AED-4A6B574B9BCD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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? --Apple-Mail=_B99AD926-A9B5-4046-8AED-4A6B574B9BCD Content-Disposition: attachment; filename=grep-highlight-matches-autodetect.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="grep-highlight-matches-autodetect.diff" Content-Transfer-Encoding: 7bit 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))))) --Apple-Mail=_B99AD926-A9B5-4046-8AED-4A6B574B9BCD--