Function: eshell-execute-file

eshell-execute-file is an autoloaded, interactive and byte-compiled function defined in em-script.el.gz.

Signature

(eshell-execute-file FILE &optional ARGS OUTPUT-TARGET ERROR-TARGET)

Documentation

Execute a series of Eshell commands in FILE, passing ARGS.

If OUTPUT-TARGET is t (interactively, with the prefix argument), write the command's standard output to the current buffer at point. If nil, don't write the output anywhere. For any other value, output to that Eshell target (see eshell-get-target).

ERROR-TARGET is similar to OUTPUT-TARGET, except that it controls where to write standard error, and a nil value means to write standard error to the same place as standard output. (To suppress standard error, you can write to the Eshell virtual target "/dev/null".)

Comments begin with #.

Probably introduced at or before Emacs version 31.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-script.el.gz
;;;###autoload
(defun eshell-execute-file (file &optional args output-target error-target)
  "Execute a series of Eshell commands in FILE, passing ARGS.
If OUTPUT-TARGET is t (interactively, with the prefix argument), write
the command's standard output to the current buffer at point.  If nil,
don't write the output anywhere.  For any other value, output to that
Eshell target (see `eshell-get-target').

ERROR-TARGET is similar to OUTPUT-TARGET, except that it controls where
to write standard error, and a nil value means to write standard error
to the same place as standard output.  (To suppress standard error, you
can write to the Eshell virtual target \"/dev/null\".)

Comments begin with `#'."
  (interactive (list (read-file-name "Execute file: " nil nil t)
                     nil (not (not current-prefix-arg))))
  (let ((eshell-non-interactive-p t)
        (stdout (if (eq output-target t) (current-buffer) output-target))
        (stderr (if (eq error-target t) (current-buffer) error-target)))
    (with-temp-buffer
      (eshell-mode)
      (eshell-do-eval
       `(eshell-with-handles (',stdout 'insert ',stderr 'insert)
          (let ((eshell-current-subjob-p))
            ,(eshell--source-file file args)))
       t))))