From 1e53bb4bf2754c724bcb894e730fd77e25dae80c Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sat, 14 Sep 2013 17:10:45 -0700 Subject: * 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 --- lisp/eshell/esh-cmd.el | 6 +++++- lisp/eshell/esh-var.el | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'lisp/eshell') 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." 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)) 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: (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)))) -- cgit v1.2.1