From: Lars Ingebrigtsen <larsi@gnus.org>
To: Damien Merenne <dam@cosinux.org>
Cc: 52178@debbugs.gnu.org
Subject: bug#52178: 29.0.50; process-environment not used in async-shell-command
Date: Mon, 29 Nov 2021 15:38:12 +0100 [thread overview]
Message-ID: <87zgpnxc17.fsf@gnus.org> (raw)
In-Reply-To: <8735nf3zvf.fsf@workstation.lan> (Damien Merenne's message of "Mon, 29 Nov 2021 13:33:40 +0100")
Damien Merenne <dam@cosinux.org> writes:
> When running an async process, the value of `process-environment' is
> lost, in 'emacs -Q' scratch buffer:
>
> (let ((process-environment "EDITOR=test"))
> (shell-command "env &"))
I think you mean
(let ((process-environment '("EDITOR=test")))
(shell-command "env &"))
> and the output is my normal environment, not the limited one. When
> removing the &, it works okay. I managed to pinpoint the problem to the
> call to `with-current-buffer' in simple.el:4229. As process-environment
> is buffer local, it is not passed in the process buffer.
process-environment is not buffer-local by default, though, so the test
case works fine normally. Do you have a complete case to reproduce the
problem, starting from "emacs -Q"?
> This patch fixes it but I have no idea if this is the correct way to
> fix it:
The patch wasn't complete, so I've recreated it and included below for
reference.
It makes sense to me, but I'd like to know where this fixes anything
before applying.
diff --git a/lisp/simple.el b/lisp/simple.el
index 84928caa31..e38988f916 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4194,7 +4194,8 @@ shell-command
(or output-buffer shell-command-buffer-name-async)))
(bname (buffer-name buffer))
(proc (get-buffer-process buffer))
- (directory default-directory))
+ (directory default-directory)
+ (process-env process-environment))
;; Remove the ampersand.
(setq command (substring command 0 (match-beginning 0)))
;; Ask the user what to do with already running process.
@@ -4237,7 +4238,7 @@ shell-command
(format "COLUMNS=%d"
async-shell-command-width)))
(comint-term-environment)
- process-environment)))
+ process-env)))
(setq proc
(start-process-shell-command "Shell" buffer command)))
(setq mode-line-process '(":%s"))
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2021-11-29 14:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-29 12:33 bug#52178: 29.0.50; process-environment not used in async-shell-command Damien Merenne
2021-11-29 14:38 ` Lars Ingebrigtsen [this message]
2021-11-29 20:34 ` Damien Merenne
2022-01-15 13:07 ` Lars Ingebrigtsen
2022-01-15 21:39 ` Michael Heerdegen
2022-01-16 10:49 ` Damien Merenne
2022-01-16 10:51 ` Damien Merenne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zgpnxc17.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=52178@debbugs.gnu.org \
--cc=dam@cosinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).