]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix for Eshell's for loop.
authorChong Yidong <cyd@gnu.org>
Sat, 20 Oct 2012 11:54:24 +0000 (19:54 +0800)
committerChong Yidong <cyd@gnu.org>
Sat, 20 Oct 2012 11:54:24 +0000 (19:54 +0800)
* eshell/esh-cmd.el (eshell-rewrite-for-command): Copy the body
list explicitly.

Fixes: debbugs:12571
lisp/ChangeLog
lisp/eshell/esh-cmd.el

index 96267eacb8932f9741b074072465c89d5838afe0..8b17f91877dddb98a6df4c55147f2120f47173f1 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-20  Chong Yidong  <cyd@gnu.org>
+
+       * eshell/esh-cmd.el (eshell-rewrite-for-command): Copy the body
+       list explicitly (Bug#12571).
+
 2012-10-20  Arne Jørgensen  <arne@arnested.dk>
 
        * progmodes/flymake.el (flymake-create-temp-inplace): Use
index 5a10721387b758e0e14c56c8410305ca0724543e..e6e89d83b7c7a1b9159634752e48e9ae581d5ea5 100644 (file)
@@ -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))))))