Function: eshell/which

eshell/which is a byte-compiled function defined in esh-cmd.el.gz.

Signature

(eshell/which COMMAND &rest NAMES)

Documentation

Identify the COMMAND, and where it is located.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-cmd.el.gz
(defun eshell/which (command &rest names)
  "Identify the COMMAND, and where it is located."
  (let (not-found)
    (dolist (name (cons command names))
      (condition-case error
          (eshell-printn
           (catch 'found
             (run-hook-wrapped
              'eshell-named-command-hook
              (lambda (hook)
                (when-let* (((symbolp hook))
                            (which-func (get hook 'eshell-which-function))
                            (result (funcall which-func command)))
                  (throw 'found result))))
             (eshell-plain-command--which name)))
        (error (eshell-error (format "which: %s\n" (cadr error)))
               (setq not-found t))))
    (when not-found (eshell-set-exit-info 1))))