Use 'eshell-with-handles' when executing an Eshell file

This makes sure we close the handles as we should, which is important
for writing the output to an actual file (bug#72857).

* lisp/eshell/em-script.el (esh-cmd): Require this, just to be explicit.
(eshell-execute-file): Use 'eshell-with-handles'.
This commit is contained in:
Jim Porter 2024-08-28 13:59:04 -07:00
parent 10802fb00f
commit e97ab1c413

View file

@ -24,6 +24,7 @@
;;; Code:
(require 'esh-mode)
(require 'esh-cmd)
(require 'esh-io)
;;;###esh-module-autoload
@ -127,10 +128,9 @@ Comments begin with `#'."
(with-temp-buffer
(eshell-mode)
(eshell-do-eval
`(let ((eshell-current-handles
(eshell-create-handles ,stdout 'insert ,stderr 'insert))
(eshell-current-subjob-p))
,(eshell--source-file file args))
`(eshell-with-handles (,stdout 'insert ,stderr 'insert)
(let ((eshell-current-subjob-p))
,(eshell--source-file file args)))
t))))
(cl-defstruct (eshell-princ-target