mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Return non-zero exit status when Eshell's "which" fails to find a command
* lisp/eshell/esh-cmd.el (eshell/which): Set exit status to 1 if we couldn't find any of the commands (bug#74739).
This commit is contained in:
parent
1098ae2896
commit
b6c91cdf54
1 changed files with 16 additions and 13 deletions
|
|
@ -1381,19 +1381,22 @@ have been replaced by constants."
|
|||
|
||||
(defun eshell/which (command &rest names)
|
||||
"Identify the COMMAND, and where it is located."
|
||||
(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)))))))
|
||||
(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))))
|
||||
|
||||
(put 'eshell/which 'eshell-no-numeric-conversions t)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue