Subject: [PATCH] * lisp/man.el (Man-getpage-in-background): always use shell-file-name
From: Nika Otiashvili <[email-masked]>
To: [email-masked]
Date: Mon, 21 Dec 2020 23:24:13 +0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,
First time sending a patch to bug-gnu-emacs, not sure if this is the
correct format.
Please indicate any errors I made in my formatting of the email or the
attached patch file.

Regards,
Nika Otiashvili
From e27cc04bc2a1ca10d5e89ad585fc59eb0d462b8d Mon Sep 17 00:00:00 2001
From: Nika Otiashvili <[email-masked]>
Date: Mon, 21 Dec 2020 23:14:28 +0400
Subject: [PATCH] * lisp/man.el (Man-getpage-in-background): always use
 shell-file-name

Copyright-paperwork-exempt: yes
; Reasons for change:
;
; * M-m man invokes Man-getpage-in-background, which launches
;   shell-file-name only when system-type is cygwin or windows-nt,
;   otherwise it launches /bin/sh. Some users may not have /bin/sh.
;
; * /bin/sh, when launched this way, runs through the user's
;   runtime configurations (.bashrc, .zshrc ...), however it does
;   not launch subshells even if there are appropriate shebangs at
;   the top of the rc files. Neither "#! /bin/bash", nor
;   "#! /usr/bin/env bash" launches bash. This causes the process
;   to crash if the rc files are incompatible with the user's
;   /bin/sh and instead of the rendered man page, it gives an error
;   message in the new buffer.
;
; * It is reasonable for the user to expect that any function that
;   launches a subshell under emacs should respect the
;   shell-file-name variable that they have configured.
---
 lisp/man.el | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lisp/man.el b/lisp/man.el
index c914ec34b97..c257536aeca 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1123,11 +1123,7 @@ Man-getpage-in-background
 	(Man-start-calling
 	 (if (fboundp 'make-process)
 	     (let ((proc (start-process
-			  manual-program buffer
-			  (if (memq system-type '(cygwin windows-nt))
-			      shell-file-name
-			    "sh")
-			  shell-command-switch
+                          manual-program buffer shell-file-name shell-command-switch
 			  (format (Man-build-man-command) man-args))))
 	       (set-process-sentinel proc 'Man-bgproc-sentinel)
 	       (set-process-filter proc 'Man-bgproc-filter))
-- 
2.20.1