Function: eshell-command-result
eshell-command-result is an autoloaded and byte-compiled function
defined in eshell.el.gz.
Signature
(eshell-command-result COMMAND &optional STATUS-VAR)
Documentation
Execute the given Eshell COMMAND, and return the result.
The result might be any Lisp object. If STATUS-VAR is a symbol, it will be set to the exit status of the command. This is the only way to determine whether the value returned corresponding to a successful execution.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/eshell.el.gz
;;;###autoload
(defun eshell-command-result (command &optional status-var)
"Execute the given Eshell COMMAND, and return the result.
The result might be any Lisp object.
If STATUS-VAR is a symbol, it will be set to the exit status of the
command. This is the only way to determine whether the value returned
corresponding to a successful execution."
;; a null command produces a null, successful result
(if (not command)
(ignore
(if (and status-var (symbolp status-var))
(set status-var 0)))
(with-temp-buffer
(let ((eshell-non-interactive-p t))
(eshell-mode)
(let ((result (eshell-do-eval
(list 'eshell-commands
(list 'eshell-command-to-value
(eshell-parse-command command)))
t)))
(cl-assert (eq (car result) 'quote))
(if (and status-var (symbolp status-var))
(set status-var eshell-last-command-status))
(cadr result))))))