Simplify iteration in Eshell for loops

The previous code fixed an issue in Eshell's iterative evaluation
where deferred commands caused an infinite loop (see bug#12571).
However, with the fix to unwinding let forms in 'eshell-do-eval' (see
bug#59469), we can just write this code as we normally would
(bug#61954).

* lisp/eshell/esh-cmd.el (eshell-rewrite-for-command): Simplify.
This commit is contained in:
Jim Porter 2023-01-26 23:18:42 -08:00
parent 0330cff65a
commit 67a2b320f6

View file

@ -533,25 +533,23 @@ implemented via rewriting, rather than as a function."
(equal (nth 2 terms) "in"))
(let ((body (car (last terms))))
(setcdr (last terms 2) nil)
`(let ((for-items
(copy-tree
(append
,@(mapcar
(lambda (elem)
(if (listp elem)
elem
`(list ,elem)))
(cdr (cddr terms))))))
(eshell-command-body '(nil))
`(let ((for-items
(append
,@(mapcar
(lambda (elem)
(if (listp elem)
elem
`(list ,elem)))
(nthcdr 3 terms))))
(eshell-command-body '(nil))
(eshell-test-body '(nil)))
(while (car for-items)
(let ((,(intern (cadr terms)) (car for-items))
(while for-items
(let ((,(intern (cadr terms)) (car for-items))
(eshell--local-vars (cons ',(intern (cadr terms))
eshell--local-vars)))
eshell--local-vars)))
(eshell-protect
,(eshell-invokify-arg body t)))
(setcar for-items (cadr for-items))
(setcdr for-items (cddr for-items)))
(setq for-items (cdr for-items)))
(eshell-close-handles)))))
(defun eshell-structure-basic-command (func names keyword test body