aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell
diff options
context:
space:
mode:
authorStefan Monnier2011-10-30 04:01:31 -0400
committerStefan Monnier2011-10-30 04:01:31 -0400
commitc1e2f5fa6977e86cf2797c4f4627e518b40c5182 (patch)
treef0e373f5a3a0a2c856c10018105a3b86fe37f97e /lisp/eshell
parent1bc4c3aeb94bac3ff93a1e1a57d93d0d65824f59 (diff)
downloademacs-c1e2f5fa6977e86cf2797c4f4627e518b40c5182.tar.gz
emacs-c1e2f5fa6977e86cf2797c4f4627e518b40c5182.zip
* lisp/eshell/esh-cmd.el (eshell-rewrite-for-command): Fix last change.
(eshell-do-eval): Handle multiple expressions in `while' body. Fixes: debbugs:9907
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/esh-cmd.el39
1 files changed, 24 insertions, 15 deletions
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index cac33f130f1..52c8c2ddc20 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -480,19 +480,25 @@ implemented via rewriting, rather than as a function."
480 (let ((body (car (last terms)))) 480 (let ((body (car (last terms))))
481 (setcdr (last terms 2) nil) 481 (setcdr (last terms 2) nil)
482 `(let ((for-items 482 `(let ((for-items
483 (append 483 ;; Apparently, eshell-do-eval only works for immutable
484 ,@(mapcar 484 ;; let-bindings, i.e. we cannot use `setq' on `for-items'.
485 (lambda (elem) 485 ;; Instead we store the list in the car of a cons-cell (which
486 (if (listp elem) 486 ;; acts as a ref-cell) so we can setcar instead of setq.
487 elem 487 (list
488 `(list ,elem))) 488 (append
489 (cdr (cddr terms))))) 489 ,@(mapcar
490 (lambda (elem)
491 (if (listp elem)
492 elem
493 `(list ,elem)))
494 (cdr (cddr terms))))))
490 (eshell-command-body '(nil)) 495 (eshell-command-body '(nil))
491 (eshell-test-body '(nil))) 496 (eshell-test-body '(nil)))
492 (while (consp for-items) 497 (while (consp (car for-items))
493 (let ((,(intern (cadr terms)) (car for-items))) 498 (let ((,(intern (cadr terms)) (caar for-items)))
494 (eshell-protect ,(eshell-invokify-arg body t))) 499 (eshell-protect
495 (setq for-items (cdr for-items))) 500 ,(eshell-invokify-arg body t)))
501 (setcar for-items (cdar for-items)))
496 (eshell-close-handles 502 (eshell-close-handles
497 eshell-last-command-status 503 eshell-last-command-status
498 (list 'quote eshell-last-command-result)))))) 504 (list 'quote eshell-last-command-result))))))
@@ -805,9 +811,9 @@ This is used on systems where `start-process' is not supported."
805 (when (memq (car head) eshell-deferrable-commands) 811 (when (memq (car head) eshell-deferrable-commands)
806 (ignore 812 (ignore
807 (setcar head 813 (setcar head
808 (intern-soft 814 (intern-soft
809 (concat (symbol-name (car head)) "*")))))) 815 (concat (symbol-name (car head)) "*"))))))
810 ;; The last process in the pipe should get its handles 816 ;; The last process in the pipe should get its handles
811 ;; redirected as we found them before running the pipe. 817 ;; redirected as we found them before running the pipe.
812 ,(if (null (cdr pipeline)) 818 ,(if (null (cdr pipeline))
813 `(progn 819 `(progn
@@ -1031,7 +1037,10 @@ be finished later after the completion of an asynchronous subprocess."
1031 (unless (car eshell-test-body) 1037 (unless (car eshell-test-body)
1032 (setcar eshell-test-body (eshell-copy-tree (car args)))) 1038 (setcar eshell-test-body (eshell-copy-tree (car args))))
1033 (while (cadr (eshell-do-eval (car eshell-test-body))) 1039 (while (cadr (eshell-do-eval (car eshell-test-body)))
1034 (setcar eshell-command-body (eshell-copy-tree (cadr args))) 1040 (setcar eshell-command-body
1041 (if (cddr args)
1042 `(progn ,@(eshell-copy-tree (cdr args)))
1043 (eshell-copy-tree (cadr args))))
1035 (eshell-do-eval (car eshell-command-body) synchronous-p) 1044 (eshell-do-eval (car eshell-command-body) synchronous-p)
1036 (setcar eshell-command-body nil) 1045 (setcar eshell-command-body nil)
1037 (setcar eshell-test-body (eshell-copy-tree (car args)))) 1046 (setcar eshell-test-body (eshell-copy-tree (car args))))