From: Chong Yidong Date: Sat, 20 Oct 2012 11:54:24 +0000 (+0800) Subject: Fix for Eshell's for loop. X-Git-Tag: emacs-24.2.90~211^2~30 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=045ef729040afa82576045f51a6738114b8f3064;p=emacs.git Fix for Eshell's for loop. * eshell/esh-cmd.el (eshell-rewrite-for-command): Copy the body list explicitly. Fixes: debbugs:12571 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 96267eacb89..8b17f91877d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-10-20 Chong Yidong + + * eshell/esh-cmd.el (eshell-rewrite-for-command): Copy the body + list explicitly (Bug#12571). + 2012-10-20 Arne Jørgensen * progmodes/flymake.el (flymake-create-temp-inplace): Use 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))))))