1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-30 08:09:04 +00:00

* 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
This commit is contained in:
Glenn Morris 2013-09-14 17:10:45 -07:00
parent 0d8863b3b1
commit 1e53bb4bf2
5 changed files with 26 additions and 3 deletions

View File

@ -1,3 +1,9 @@
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.

View File

@ -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))

View File

@ -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))))

View File

@ -1,3 +1,9 @@
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):

View File

@ -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