unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Christopher Howard <christopher@librehacker.com>, 73479@debbugs.gnu.org
Cc: eliz@gnu.org
Subject: bug#73479: 30.0.91; eshell: error on some env calls
Date: Wed, 25 Sep 2024 12:08:07 -0700	[thread overview]
Message-ID: <bd053be5-dc62-5cf5-22ec-5da4651171a0@gmail.com> (raw)
In-Reply-To: <87ldzfsm5n.fsf@librehacker.com>

[-- Attachment #1: Type: text/plain, Size: 492 bytes --]

On 9/25/2024 10:01 AM, Christopher Howard wrote:
> 
> 1. emacs -Q
> 2. M-x eshell
> 3. env ls <ENTER>
>     or
>     env eshell <ENTER>
> 
> Note that if you are set up to use the system "env" instead, this problem won't show up. Also, it works correctly with "env FOO=bar ls", "env cd", and other combinations that I tested.

Thanks for noticing this. Here's a patch. Eli, is this ok for Emacs 30? 
It's a bug in a newly-added feature, and the fix is simple (plus it has 
a regression test).

[-- Attachment #2: 0001-Fix-executing-commands-in-Eshell-using-env-with-no-l.patch --]
[-- Type: text/plain, Size: 1802 bytes --]

From 576e79474e874414a58264212716fff379e2b70a Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Wed, 25 Sep 2024 11:59:32 -0700
Subject: [PATCH] Fix executing commands in Eshell using "env" with no local
 variables

* lisp/eshell/esh-var.el (eshell/env): Throw 'eshell-replace-command' as
needed.

* test/lisp/eshell/esh-var-tests.el
(esh-var-test/local-variables/env/no-locals): New test (bug#73479).
---
 lisp/eshell/esh-var.el            | 3 ++-
 test/lisp/eshell/esh-var-tests.el | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index f0270aca92c..1b54f1862be 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -436,7 +436,8 @@ eshell/env
      :usage "[NAME=VALUE]... [COMMAND]...")
    (if args
        (or (eshell-parse-local-variables args)
-           (eshell-named-command (car args) (cdr args)))
+           (throw 'eshell-replace-command
+                  `(eshell-named-command ,(car args) ',(cdr args))))
      (eshell-with-buffered-print
        (dolist (setting (sort (eshell-environment-variables) 'string-lessp))
          (eshell-buffered-print setting "\n"))))))
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el
index 6b0e225f05f..7b29e4a21db 100644
--- a/test/lisp/eshell/esh-var-tests.el
+++ b/test/lisp/eshell/esh-var-tests.el
@@ -669,6 +669,11 @@ esh-var-test/local-variables/env
    (eshell-match-command-output "env VAR=hello env" "VAR=hello\n")
    (should (equal (getenv "VAR") "value"))))
 
+(ert-deftest esh-var-test/local-variables/env/no-locals ()
+  "Test that \"env command\" works like \"command\"."
+  (with-temp-eshell
+   (eshell-match-command-output "env echo hi" "\\`hi\n")))
+
 \f
 ;; Variable aliases
 
-- 
2.25.1


  reply	other threads:[~2024-09-25 19:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 17:01 bug#73479: 30.0.91; eshell: error on some env calls Christopher Howard
2024-09-25 19:08 ` Jim Porter [this message]
2024-09-26  6:14   ` Eli Zaretskii
2024-09-30  1:28     ` Jim Porter

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=bd053be5-dc62-5cf5-22ec-5da4651171a0@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=73479@debbugs.gnu.org \
    --cc=christopher@librehacker.com \
    --cc=eliz@gnu.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).