Function: org-babel-execute:eshell
org-babel-execute:eshell is a byte-compiled function defined in
ob-eshell.el.gz.
Signature
(org-babel-execute:eshell BODY PARAMS)
Documentation
Execute a block of Eshell code BODY with PARAMS.
This function is called by org-babel-execute-src-block.
The BODY argument is code which can be executed in Eshell. Eshell allows executing normal shell command and Elisp code. For more details, see Info node (eshell) Top.
The PARAMS argument is passed to org-babel-expand-body:generic (which see).
Source Code
;; Defined in /usr/src/emacs/lisp/org/ob-eshell.el.gz
(defun org-babel-execute:eshell (body params)
"Execute a block of Eshell code BODY with PARAMS.
This function is called by `org-babel-execute-src-block'.
The BODY argument is code which can be executed in Eshell.
Eshell allows executing normal shell command and Elisp code.
For more details, see Info node `(eshell) Top'.
The PARAMS argument is passed to
`org-babel-expand-body:generic' (which see)."
(let* ((session (org-babel-eshell-initiate-session
(cdr (assq :session params))))
(full-body (org-babel-expand-body:generic
body params (org-babel-variable-assignments:eshell params))))
(if session
(progn
(with-current-buffer session
(dolist (line (split-string full-body "\n"))
(goto-char eshell-last-output-end)
(insert line)
(eshell-send-input))
;; get output of last input
;; TODO: collect all output instead of last command's output.
(goto-char eshell-last-input-end)
(buffer-substring-no-properties (point) eshell-last-output-start)))
(with-temp-buffer
(eshell-command full-body t)
(buffer-string)))))