eshell--test-body (copy-tree (car args)))))
((eq (car form) 'if)
(eshell-manipulate form "evaluating if condition"
- (setcar args (eshell-do-eval (car args) synchronous-p)))
- (eshell-do-eval
- (cond
- ((eval (car args)) ; COND is non-nil
- (cadr args))
- ((cdddr args) ; Multiple ELSE forms
- `(progn ,@(cddr args)))
- (t ; Zero or one ELSE forms
- (caddr args)))
- synchronous-p))
+ ;; Evaluate the condition and replace our `if' form with
+ ;; THEN or ELSE as appropriate.
+ (let ((new-form
+ (cond
+ ((cadr (eshell-do-eval (car args) synchronous-p))
+ (cadr args)) ; COND is non-nil
+ ((cdddr args)
+ `(progn ,@(cddr args))) ; Multiple ELSE forms
+ (t
+ (caddr args))))) ; Zero or one ELSE forms
+ (if (consp new-form)
+ (progn
+ (setcar form (car new-form))
+ (setcdr form (cdr new-form)))
+ (setcar form 'progn)
+ (setcdr form new-form))))
+ (eshell-do-eval form synchronous-p))
((eq (car form) 'setcar)
(setcar (cdr args) (eshell-do-eval (cadr args) synchronous-p))
(eval form))