aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2013-09-14 17:10:45 -0700
committerGlenn Morris2013-09-14 17:10:45 -0700
commit1e53bb4bf2754c724bcb894e730fd77e25dae80c (patch)
tree446081c5b29310e9bf0a798c75b6505b867a5b81
parent0d8863b3b1829f8e53da8dff9ffc2dab60390da6 (diff)
downloademacs-1e53bb4bf2754c724bcb894e730fd77e25dae80c.tar.gz
emacs-1e53bb4bf2754c724bcb894e730fd77e25dae80c.zip
* 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
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/eshell/esh-cmd.el6
-rw-r--r--lisp/eshell/esh-var.el1
-rw-r--r--test/ChangeLog6
-rw-r--r--test/automated/eshell.el10
5 files changed, 26 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8384f53d946..f63a0d6681f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12013-09-15 Glenn Morris <rgm@gnu.org>
2
3 * eshell/esh-cmd.el (eshell--local-vars): New variable. (Bug#15372)
4 (eshell-rewrite-for-command): Add for loop vars to eshell--local-vars.
5 * eshell/esh-var.el (eshell-get-variable): Respect eshell--local-vars.
6
12013-09-14 Glenn Morris <rgm@gnu.org> 72013-09-14 Glenn Morris <rgm@gnu.org>
2 8
3 * eshell/esh-var.el (eshell-variable-aliases-list): Fix doc typo. 9 * eshell/esh-var.el (eshell-variable-aliases-list): Fix doc typo.
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index cc4fdd15bda..75e0e1d27c8 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -473,6 +473,8 @@ the second is ignored."
473 arg)) 473 arg))
474 474
475(defvar eshell-last-command-status) ;Define in esh-io.el. 475(defvar eshell-last-command-status) ;Define in esh-io.el.
476(defvar eshell--local-vars nil
477 "List of locally bound vars that should take precedence over env-vars.")
476 478
477(defun eshell-rewrite-for-command (terms) 479(defun eshell-rewrite-for-command (terms)
478 "Rewrite a `for' command into its equivalent Eshell command form. 480 "Rewrite a `for' command into its equivalent Eshell command form.
@@ -495,7 +497,9 @@ implemented via rewriting, rather than as a function."
495 (eshell-command-body '(nil)) 497 (eshell-command-body '(nil))
496 (eshell-test-body '(nil))) 498 (eshell-test-body '(nil)))
497 (while (car for-items) 499 (while (car for-items)
498 (let ((,(intern (cadr terms)) (car for-items))) 500 (let ((,(intern (cadr terms)) (car for-items))
501 (eshell--local-vars (cons ',(intern (cadr terms))
502 eshell--local-vars)))
499 (eshell-protect 503 (eshell-protect
500 ,(eshell-invokify-arg body t))) 504 ,(eshell-invokify-arg body t)))
501 (setcar for-items (cadr for-items)) 505 (setcar for-items (cadr for-items))
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index 8dd19618da2..3121dadace2 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -502,6 +502,7 @@ Possible options are:
502 (let ((sym (intern-soft var))) 502 (let ((sym (intern-soft var)))
503 (if (and sym (boundp sym) 503 (if (and sym (boundp sym)
504 (or eshell-prefer-lisp-variables 504 (or eshell-prefer-lisp-variables
505 (memq sym eshell--local-vars) ; bug#15372
505 (not (getenv var)))) 506 (not (getenv var))))
506 (symbol-value sym) 507 (symbol-value sym)
507 (getenv var)))) 508 (getenv var))))
diff --git a/test/ChangeLog b/test/ChangeLog
index 21b22425fb6..85119db69f2 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
12013-09-15 Glenn Morris <rgm@gnu.org>
2
3 * automated/eshell.el (eshell-test/for-name-shadow-loop):
4 New test. (Bug#15372)
5 (eshell-test/for-loop, eshell-test/for-name-loop): Doc fix.
6
12013-09-13 Glenn Morris <rgm@gnu.org> 72013-09-13 Glenn Morris <rgm@gnu.org>
2 8
3 * automated/eshell.el (with-temp-eshell): 9 * automated/eshell.el (with-temp-eshell):
diff --git a/test/automated/eshell.el b/test/automated/eshell.el
index b9eb31660f1..6f7a35371a6 100644
--- a/test/automated/eshell.el
+++ b/test/automated/eshell.el
@@ -75,17 +75,23 @@
75 (should (equal (eshell-test-command-result "(+ 1 2)") 3))) 75 (should (equal (eshell-test-command-result "(+ 1 2)") 3)))
76 76
77(ert-deftest eshell-test/for-loop () 77(ert-deftest eshell-test/for-loop ()
78 "Test `eshell-command-result' with an elisp command." 78 "Test `eshell-command-result' with a for loop.."
79 (let ((process-environment (cons "foo" process-environment))) 79 (let ((process-environment (cons "foo" process-environment)))
80 (should (equal (eshell-test-command-result 80 (should (equal (eshell-test-command-result
81 "for foo in 5 { echo $foo }") 5)))) 81 "for foo in 5 { echo $foo }") 5))))
82 82
83(ert-deftest eshell-test/for-name-loop () ;Bug#15231 83(ert-deftest eshell-test/for-name-loop () ;Bug#15231
84 "Test `eshell-command-result' with an elisp command." 84 "Test `eshell-command-result' with a for loop using `name'."
85 (let ((process-environment (cons "name" process-environment))) 85 (let ((process-environment (cons "name" process-environment)))
86 (should (equal (eshell-test-command-result 86 (should (equal (eshell-test-command-result
87 "for name in 3 { echo $name }") 3)))) 87 "for name in 3 { echo $name }") 3))))
88 88
89(ert-deftest eshell-test/for-name-shadow-loop () ; bug#15372
90 "Test `eshell-command-result' with a for loop using an env-var."
91 (let ((process-environment (cons "name=env-value" process-environment)))
92 (should (equal (eshell-test-command-result
93 "for name in 3 { echo $name }") 3))))
94
89(ert-deftest eshell-test/lisp-command-args () 95(ert-deftest eshell-test/lisp-command-args ()
90 "Test `eshell-command-result' with elisp and trailing args. 96 "Test `eshell-command-result' with elisp and trailing args.
91Test that trailing arguments outside the S-expression are 97Test that trailing arguments outside the S-expression are