summaryrefslogtreecommitdiff
path: root/lisp/eshell
diff options
context:
space:
mode:
authorChong Yidong <cyd@gnu.org>2012-10-20 19:54:24 +0800
committerChong Yidong <cyd@gnu.org>2012-10-20 19:54:24 +0800
commit045ef729040afa82576045f51a6738114b8f3064 (patch)
tree79bcca46eb13d541e7015134268b342778875069 /lisp/eshell
parent3503c798921ee6b8f1cc960d9406b69623eb5470 (diff)
downloademacs-045ef729040afa82576045f51a6738114b8f3064.tar.gz
Fix for Eshell's for loop.
* eshell/esh-cmd.el (eshell-rewrite-for-command): Copy the body list explicitly. Fixes: debbugs:12571
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/esh-cmd.el28
1 files changed, 15 insertions, 13 deletions
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index 5a10721387b..e6e89d83b7c 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -484,20 +484,22 @@ implemented via rewriting, rather than as a function."
(let ((body (car (last terms))))
(setcdr (last terms 2) nil)
`(let ((for-items
- (append
- ,@(mapcar
- (lambda (elem)
- (if (listp elem)
- elem
- `(list ,elem)))
- (cdr (cddr terms)))))
- (eshell-command-body '(nil))
+ (copy-tree
+ (append
+ ,@(mapcar
+ (lambda (elem)
+ (if (listp elem)
+ elem
+ `(list ,elem)))
+ (cdr (cddr terms))))))
+ (eshell-command-body '(nil))
(eshell-test-body '(nil)))
- (while (consp for-items)
- (let ((,(intern (cadr terms)) (car for-items)))
- (eshell-protect
- ,(eshell-invokify-arg body t)))
- (setq for-items (cdr for-items)))
+ (while (car for-items)
+ (let ((,(intern (cadr terms)) (car for-items)))
+ (eshell-protect
+ ,(eshell-invokify-arg body t)))
+ (setcar for-items (cadr for-items))
+ (setcdr for-items (cddr for-items)))
(eshell-close-handles
eshell-last-command-status
(list 'quote eshell-last-command-result))))))