From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Federico Tedin Newsgroups: gmane.emacs.bugs Subject: bug#25496: 25.1.91; INSIDE_EMACS env variable is not set in eshell Date: Sun, 08 Mar 2020 17:50:51 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="25716"; mail-complaints-to="usenet@ciao.gmane.io" To: 25496@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 08 17:52:17 2020 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 1jAzA1-0006Zq-9I for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 Mar 2020 17:52:17 +0100 Original-Received: from localhost ([::1]:59640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAzA0-0003dq-BV for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 Mar 2020 12:52:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46992) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAz9r-0003dk-Dx for bug-gnu-emacs@gnu.org; Sun, 08 Mar 2020 12:52:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAz9n-0000dw-9q for bug-gnu-emacs@gnu.org; Sun, 08 Mar 2020 12:52:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43247) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jAz9n-0000dh-3P for bug-gnu-emacs@gnu.org; Sun, 08 Mar 2020 12:52:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jAz9m-0007p1-0U for bug-gnu-emacs@gnu.org; Sun, 08 Mar 2020 12:52:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Federico Tedin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Mar 2020 16:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25496 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 25496-submit@debbugs.gnu.org id=B25496.158368626129977 (code B ref 25496); Sun, 08 Mar 2020 16:52:01 +0000 Original-Received: (at 25496) by debbugs.gnu.org; 8 Mar 2020 16:51:01 +0000 Original-Received: from localhost ([127.0.0.1]:49220 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAz8n-0007nN-7V for submit@debbugs.gnu.org; Sun, 08 Mar 2020 12:51:01 -0400 Original-Received: from mail-wm1-f48.google.com ([209.85.128.48]:36644) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAz8l-0007nA-FW for 25496@debbugs.gnu.org; Sun, 08 Mar 2020 12:50:59 -0400 Original-Received: by mail-wm1-f48.google.com with SMTP id g62so2796828wme.1 for <25496@debbugs.gnu.org>; Sun, 08 Mar 2020 09:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=QwZEE6z/53nx+zUrgUfuD+yILEuDNQP3Aavrfq1xzHY=; b=Yx7uV5cJyQi8oh5dvMxUAKjiJV/grWXaNRcZZnBZTC5iNLIsWq2CqWhJaDMzPQYP7c 98EmvDREs1KHvuL2LyxOuxTjjaRvJ9cQeVQ1fypy6vgWI/6uNC3r8wden3eL8vzYSrte j7ixIIpE1X28TO8I3Lwyz5eB0pDRyDyvTK6gUmnGcvCa39J8+C8650Sp+EfRNjEkihlY SoD1bFPNz7Wrnm5RRQuU2lUbtJLqP9xIQALk9/uDpTcFVAvPt0n2XUa6hb74ni0gqtK3 Ija1BkCnu7sdxDTna2JFuN+f+a9G673kBkIZQgafhpSGO5PEHMJaKA53RAwthHInJD+A gtaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=QwZEE6z/53nx+zUrgUfuD+yILEuDNQP3Aavrfq1xzHY=; b=PG98x5jvDv2ONSKGIpVbWz+x2MOcuW/n/i7KX1OjOgCaiVwn5F45SvSOs04H5tX+JI anblFSEHvLiZ+T4VhA+uBI+3i4e7C13uH0l/UVqWBP6UyAwSgH5HXCIEktSDXBRefNTL 1FE3+TaZaDbVnpXniiU4UbBEwlEGk37b2iI0e7eX0AmFXHE3tdHGKkBgMoxzSiAejnbj JcMBm4FzJob2ZZbvRn1W7jZKZU4dT6EIXhdW+zUKfLDIoSDvbK0OL4PjEoJkKDAj9MWu 7YyGBZkQvi5sk3igR5dpW71Wf9QyyRkNEd0KuPQPfa/2tqDeYC+4YBlMd9eXCxIlgOM4 GIYA== X-Gm-Message-State: ANhLgQ001kC0fWGDy5PmWP8E9F6ioofU6o2a17Kc/m8TLC6cpIP6DmGX kVVs5OmdeN0cSUmcmbV/hv7eLTNucss= X-Google-Smtp-Source: ADFU+vvLXyKzEJY0vnvKurEbTWsN7O2TpXsQjIn0nAb3CMECpnFUkbZvunL0k6KSIf0ZjVSb3j38yw== X-Received: by 2002:a7b:c1cf:: with SMTP id a15mr16643265wmj.152.1583686253172; Sun, 08 Mar 2020 09:50:53 -0700 (PDT) Original-Received: from BERMB00016 ([2a02:8109:8ac0:2ff0:3993:e710:f57a:e4fb]) by smtp.gmail.com with ESMTPSA id u17sm34032615wrq.74.2020.03.08.09.50.52 for <25496@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Mar 2020 09:50:52 -0700 (PDT) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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:177057 Archived-At: --=-=-= Content-Type: text/plain Didn't realize that Bug#39596 was merged with this one, I'll attach my patch here just in case. - Fede --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Copy-INSIDE_EMACS-env-variable-to-subprocesses-in-Es.patch >From cf93960de7d3d92ccb7a5465851bbcb55a0f20d9 Mon Sep 17 00:00:00 2001 From: Federico Tedin Date: Wed, 19 Feb 2020 00:11:35 +0100 Subject: [PATCH] Copy INSIDE_EMACS env variable to subprocesses in Eshell * lisp/eshell/em-dirs.el (eshell-dirs-initialize): Add INSIDE_EMACS variable to buffer-local value of eshell-variable-aliases-alist. * lisp/eshell/esh-var.el (eshell-variable-aliases-list): Update doc string; remove mention of eshell-user-aliases-list and explain that variables can optionally be copied to subprocesses' environments. * test/lisp/eshell/eshell-tests.el (eshell-test/inside-emacs-var): Add test for the INSIDE_EMACS variable. * etc/NEWS: Announce changes. --- etc/NEWS | 6 ++++++ lisp/eshell/em-dirs.el | 3 +++ lisp/eshell/esh-var.el | 11 ++++++----- test/lisp/eshell/eshell-tests.el | 9 ++++++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 1f8e6049a8..238184df24 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -120,6 +120,12 @@ To revert to the previous behaviour, unconditionally aborts the current edebug instrumentation with the supplied error message. +** Eshell + +--- +*** Environment variable INSIDE_EMACS is now copied to subprocesses. +Its value equals the result of evaluating '(format "%s,eshell" emacs-version)'. + ** Tramp +++ diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index 1949e5dc8f..b478ee028a 100644 --- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el @@ -191,6 +191,9 @@ eshell-dirs-initialize (unless (ring-empty-p eshell-last-dir-ring) (expand-file-name (ring-ref eshell-last-dir-ring 0)))) + t) + ("INSIDE_EMACS" ,(lambda (_indices) + (format "%s,eshell" emacs-version)) t)))) (when eshell-cd-on-directory diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 327a1def46..4231be92fb 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -179,10 +179,8 @@ eshell-variable-aliases-list (eshell-apply-indices eshell-command-arguments indices))))) "This list provides aliasing for variable references. -It is very similar in concept to what `eshell-user-aliases-list' does -for commands. Each member of this defines the name of a command, -and the Lisp value to return for that variable if it is accessed -via the syntax `$NAME'. +Each member of this defines the name of a command, and the Lisp value +to return for that variable if it is accessed via the syntax `$NAME'. If the value is a function, that function will be called with two arguments: the list of the indices that was used in the reference, and @@ -190,7 +188,10 @@ eshell-variable-aliases-list For example, a reference of `$NAME[10][20]' would result in the function for alias `NAME' being called (assuming it were aliased to a function), and the arguments passed to this function would be the list -'(10 20)', and nil." +'(10 20)', and nil. + +Additionally, each member may specify if it should be copied to the +environment of created subprocesses." :type '(repeat (list string sexp (choice (const :tag "Copy to environment" t) (const :tag "Use only in Eshell" nil))))) diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index 026818ab06..f98e4ce92b 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el @@ -167,7 +167,14 @@ eshell-test/last-arg-var "Test using the \"last arg\" ($_) variable" (with-temp-eshell (eshell-command-result-p "+ 1 2; + $_ 4" - "3\n6\n"))) + "3\n6\n"))) + +(ert-deftest eshell-test/inside-emacs-var () + "Test presence of \"INSIDE_EMACS\" in subprocesses" + (with-temp-eshell + (eshell-command-result-p "env" + (format "INSIDE_EMACS=%s,eshell" + emacs-version)))) (ert-deftest eshell-test/escape-nonspecial () "Test that \"\\c\" and \"c\" are equivalent when \"c\" is not a -- 2.21.1 (Apple Git-122.3) --=-=-=--