From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#52178: 29.0.50; process-environment not used in async-shell-command Date: Mon, 29 Nov 2021 15:38:12 +0100 Message-ID: <87zgpnxc17.fsf@gnus.org> References: <8735nf3zvf.fsf@workstation.lan> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35671"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 52178@debbugs.gnu.org To: Damien Merenne Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 29 15:39:33 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 1mrhoY-00092v-QQ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 Nov 2021 15:39:30 +0100 Original-Received: from localhost ([::1]:54922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrhoX-0000Sc-1z for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 Nov 2021 09:39:29 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrho6-0007mf-Mb for bug-gnu-emacs@gnu.org; Mon, 29 Nov 2021 09:39:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54260) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mrho6-0003Nw-Dj for bug-gnu-emacs@gnu.org; Mon, 29 Nov 2021 09:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mrho6-0000ML-BH for bug-gnu-emacs@gnu.org; Mon, 29 Nov 2021 09:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Nov 2021 14:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52178 X-GNU-PR-Package: emacs Original-Received: via spool by 52178-submit@debbugs.gnu.org id=B52178.16381967071314 (code B ref 52178); Mon, 29 Nov 2021 14:39:02 +0000 Original-Received: (at 52178) by debbugs.gnu.org; 29 Nov 2021 14:38:27 +0000 Original-Received: from localhost ([127.0.0.1]:37569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mrhnW-0000L8-MX for submit@debbugs.gnu.org; Mon, 29 Nov 2021 09:38:26 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:58374) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mrhnU-0000Kr-BG for 52178@debbugs.gnu.org; Mon, 29 Nov 2021 09:38:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7i6cTxTbFrZnPLKJZstCdP5b/D4UDGw4Inv07ye54oM=; b=jqqWBrtoe2Qlv1xbAK76fTTSX8 Fi4jA38iiCLP6IvuQAA6FcKu+YcQwU7Adrf9wm8VVSwGUFrr0KpHW+xML5IM08sauTJcwm9VKnkmZ l8VEtHgS5zfpAaNgtf61MN4gq0hWr+bJiHCu9FjPWi7e/5y9bq/4QlcMTP0py8cL6VDs=; Original-Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mrhnJ-0005BA-BN; Mon, 29 Nov 2021 15:38:16 +0100 X-Now-Playing: Gazing at Taurus's _The Tunnel and the Clearing_: "Night Sky Rumba" In-Reply-To: <8735nf3zvf.fsf@workstation.lan> (Damien Merenne's message of "Mon, 29 Nov 2021 13:33:40 +0100") 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:221008 Archived-At: Damien Merenne 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