]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix executing commands in Eshell using "env" with no local variables
authorJim Porter <jporterbugs@gmail.com>
Wed, 25 Sep 2024 18:59:32 +0000 (11:59 -0700)
committerEshel Yaron <me@eshelyaron.com>
Sun, 6 Oct 2024 06:44:22 +0000 (08:44 +0200)
* 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)

lisp/eshell/esh-var.el
test/lisp/eshell/esh-var-tests.el

index 0e6c01d27741e4949f8ec87e30c6d17c496dd642..5d7ea1c36646d3291f50b3174c4bbaadbe216b6d 100644 (file)
@@ -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"))))))
index 6b0e225f05f58e81c4c9d0023680c6cacdbeb8ef..7b29e4a21db2f3accedd29d75fa28f34cdda3bed 100644 (file)
@@ -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")))
+
 \f
 ;; Variable aliases