Subject: bug#79067: 31.0.50; Cannot async-shell-command anymore

From: Manuel Giraud <[email-masked]>
Date: Mon, 21 Jul 2025 11:51:38 +0200

Manuel Giraud <[email-masked]> writes:

> Hi,
>
>>From a current build, I can't call `async-shell-command' anymore.  Here
> is my recipe:
>
>   - emacs -Q
>   - M-& ls <RET>
>
> I get the following error:
>
> shell-command: Asynchronous shell commands cannot output to current
> buffer

I'm not quite sure about the logic at play here but the following patch
fixes my issue:

diff --git a/lisp/simple.el b/lisp/simple.el
index 88886de05c4..f7f059793ca 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4715,7 +4715,8 @@ shell-command
 	;; Output goes in a separate buffer.
 	(if (string-match "[ \t]*&[ \t]*\\'" command)
 	    ;; Command ending with ampersand means asynchronous.
-            (let* ((_ (or (bufferp output-buffer)
+            (let* ((_ (or (null output-buffer)
+                          (bufferp output-buffer)
                           (stringp output-buffer)
                           (error "Asynchronous shell commands cannot output to current buffer")))
                    (buffer (get-buffer-create
-- 
Manuel Giraud