From: Jim Porter Date: Wed, 25 Sep 2024 18:59:32 +0000 (-0700) Subject: Fix executing commands in Eshell using "env" with no local variables X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=86703b8308bc2cd9336c03c71649d2b79ef3354f;p=emacs.git 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). (cherry picked from commit 11e3e0cadd46ee49007477af1335ddd5365debe2) --- diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 0e6c01d2774..5d7ea1c3664 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -436,7 +436,8 @@ the values of nil for each." :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 @@ nil, use FUNCTION instead." (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"))) + ;; Variable aliases