Commit 1e53bb4b authored by Glenn Morris's avatar Glenn Morris
Browse files

* lisp/eshell/esh-cmd.el (eshell--local-vars): New variable.

(eshell-rewrite-for-command): Add for loop vars to eshell--local-vars.

* lisp/eshell/esh-var.el (eshell-get-variable): Respect eshell--local-vars.

* test/automated/eshell.el (eshell-test/for-name-shadow-loop):
New test.
(eshell-test/for-loop, eshell-test/for-name-loop): Doc fix.

Fixes: debbugs:15372
parent 0d8863b3
2013-09-15 Glenn Morris <rgm@gnu.org>
* eshell/esh-cmd.el (eshell--local-vars): New variable. (Bug#15372)
(eshell-rewrite-for-command): Add for loop vars to eshell--local-vars.
* eshell/esh-var.el (eshell-get-variable): Respect eshell--local-vars.
2013-09-14 Glenn Morris <rgm@gnu.org>
* eshell/esh-var.el (eshell-variable-aliases-list): Fix doc typo.
......
......@@ -473,6 +473,8 @@ the second is ignored."
arg))
(defvar eshell-last-command-status) ;Define in esh-io.el.
(defvar eshell--local-vars nil
"List of locally bound vars that should take precedence over env-vars.")
(defun eshell-rewrite-for-command (terms)
"Rewrite a `for' command into its equivalent Eshell command form.
......@@ -495,7 +497,9 @@ implemented via rewriting, rather than as a function."
(eshell-command-body '(nil))
(eshell-test-body '(nil)))
(while (car for-items)
(let ((,(intern (cadr terms)) (car for-items)))
(let ((,(intern (cadr terms)) (car for-items))
(eshell--local-vars (cons ',(intern (cadr terms))
eshell--local-vars)))
(eshell-protect
,(eshell-invokify-arg body t)))
(setcar for-items (cadr for-items))
......
......@@ -502,6 +502,7 @@ Possible options are:
(let ((sym (intern-soft var)))
(if (and sym (boundp sym)
(or eshell-prefer-lisp-variables
(memq sym eshell--local-vars) ; bug#15372
(not (getenv var))))
(symbol-value sym)
(getenv var))))
......
2013-09-15 Glenn Morris <rgm@gnu.org>
* automated/eshell.el (eshell-test/for-name-shadow-loop):
New test. (Bug#15372)
(eshell-test/for-loop, eshell-test/for-name-loop): Doc fix.
2013-09-13 Glenn Morris <rgm@gnu.org>
* automated/eshell.el (with-temp-eshell):
......
......@@ -75,17 +75,23 @@
(should (equal (eshell-test-command-result "(+ 1 2)") 3)))
(ert-deftest eshell-test/for-loop ()
"Test `eshell-command-result' with an elisp command."
"Test `eshell-command-result' with a for loop.."
(let ((process-environment (cons "foo" process-environment)))
(should (equal (eshell-test-command-result
"for foo in 5 { echo $foo }") 5))))
(ert-deftest eshell-test/for-name-loop () ;Bug#15231
"Test `eshell-command-result' with an elisp command."
"Test `eshell-command-result' with a for loop using `name'."
(let ((process-environment (cons "name" process-environment)))
(should (equal (eshell-test-command-result
"for name in 3 { echo $name }") 3))))
(ert-deftest eshell-test/for-name-shadow-loop () ; bug#15372
"Test `eshell-command-result' with a for loop using an env-var."
(let ((process-environment (cons "name=env-value" process-environment)))
(should (equal (eshell-test-command-result
"for name in 3 { echo $name }") 3))))
(ert-deftest eshell-test/lisp-command-args ()
"Test `eshell-command-result' with elisp and trailing args.
Test that trailing arguments outside the S-expression are
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment