; Improve correctness of 'eshell-do-eval' in some edge cases

* lisp/eshell/esh-cmd.el (eshell-do-eval): Make sure that replacing 'if'
forms returns the correct result, and evaluate to 'nil' for 'progn'
forms with no body.
This commit is contained in:
Jim Porter 2024-07-19 18:07:36 -07:00
parent e8f38d1364
commit 8bfdee8689

View file

@ -1159,7 +1159,7 @@ have been replaced by constants."
(t
(caddr args))))) ; Zero or one ELSE forms
(unless (consp new-form)
(setq new-form (cons 'progn new-form)))
(setq new-form `(progn ,new-form)))
(setcar form (car new-form))
(setcdr form (cdr new-form))))
(eshell-do-eval form synchronous-p))
@ -1261,7 +1261,7 @@ have been replaced by constants."
(setq args (cdr args)))))
(cond
((eq (car form) 'progn)
(car (last form)))
(car (last (cdr form))))
((eq (car form) 'prog1)
(cadr form))
(t