Subject: bug#76888: 31.0.50; start-process: Spawning child process: Invalid argument

From: Michael Albinus <[email-masked]>
Date: Tue, 25 Mar 2025 13:56:31 +0100

Richard Copley <[email-masked]> writes:

Hi Richard,

> It's easy to move the call to 'start-process-shell-command' outside
> the 'with-current-buffer' form. I have patched my local emacs repo to
> do that. It works just fine for me. Whether that is the right thing to
> do I leave to your judgement. I refrain from attaching the patch since
> I do not intend to complete a copyright assignment.

Thank you for the analysis. However, I don't believe that your change is
correct. `buffer' is the working (output) buffer of
start-process-shell-command, so we shall call it here.

Instead, I've tried the appended patch. Could you, please, check? It
fixes the problem for me.

Best regards, Michael.

diff --git a/lisp/simple.el b/lisp/simple.el
index e6577ffd646..18073256063 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4723,7 +4723,11 @@ shell-command
                               (format "COLUMNS=%d"
                                       async-shell-command-width)))
                         (comint-term-environment)
-                        process-environment)))
+                        process-environment))
+                      (shell-file-name
+                       (connection-local-value shell-file-name))
+                      (shell-command-switch
+                       (connection-local-value shell-command-switch)))
 		  (setq proc
 			(start-process-shell-command "Shell" buffer command)))
 		(setq mode-line-process '(":%s"))