Function: eshell-batch-file

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

Signature

(eshell-batch-file)

Documentation

Execute an Eshell script as a batch script from the command line.

Inside your Eshell script file, you can add the following at the top in order to make it into an executable script:

  #!/usr/bin/env -S emacs --batch -f eshell-batch-file

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-script.el.gz
;;;###autoload
(defun eshell-batch-file ()
  "Execute an Eshell script as a batch script from the command line.
Inside your Eshell script file, you can add the following at the
top in order to make it into an executable script:

  #!/usr/bin/env -S emacs --batch -f eshell-batch-file"
  (let ((file (pop command-line-args-left))
        (args command-line-args-left)
        (eshell-non-interactive-p t)
        (eshell-module-loading-messages nil)
        (eshell-virtual-targets
         (append `(("/dev/stdout" ,(eshell-princ-target-create) nil)
                   ("/dev/stderr" ,(eshell-princ-target-create
                                    #'external-debugging-output)
                   nil))
                 eshell-virtual-targets)))
    (setq command-line-args-left nil)
    (with-temp-buffer
      (eshell-mode)
      (eshell-do-eval
       `(eshell-with-handles ("/dev/stdout" 'append "/dev/stderr" 'append)
          (let ((eshell-current-subjob-p))
            ,(eshell--source-file file args)))
       t))))