diff options
| author | Jim Porter | 2024-12-08 20:21:31 -0800 |
|---|---|---|
| committer | Jim Porter | 2024-12-08 20:21:31 -0800 |
| commit | b6c91cdf54168eef260e28a7866486a4d68bfc9e (patch) | |
| tree | 70eb7e642a212be69ace56d86369a23445654305 | |
| parent | 1098ae2896f458507c01afd04cb2e242227c6724 (diff) | |
| download | emacs-b6c91cdf54168eef260e28a7866486a4d68bfc9e.tar.gz emacs-b6c91cdf54168eef260e28a7866486a4d68bfc9e.zip | |
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).
| -rw-r--r-- | lisp/eshell/esh-cmd.el | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index c0015745ad5..7a146944145 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el | |||
| @@ -1381,19 +1381,22 @@ have been replaced by constants." | |||
| 1381 | 1381 | ||
| 1382 | (defun eshell/which (command &rest names) | 1382 | (defun eshell/which (command &rest names) |
| 1383 | "Identify the COMMAND, and where it is located." | 1383 | "Identify the COMMAND, and where it is located." |
| 1384 | (dolist (name (cons command names)) | 1384 | (let (not-found) |
| 1385 | (condition-case error | 1385 | (dolist (name (cons command names)) |
| 1386 | (eshell-printn | 1386 | (condition-case error |
| 1387 | (catch 'found | 1387 | (eshell-printn |
| 1388 | (run-hook-wrapped | 1388 | (catch 'found |
| 1389 | 'eshell-named-command-hook | 1389 | (run-hook-wrapped |
| 1390 | (lambda (hook) | 1390 | 'eshell-named-command-hook |
| 1391 | (when-let* (((symbolp hook)) | 1391 | (lambda (hook) |
| 1392 | (which-func (get hook 'eshell-which-function)) | 1392 | (when-let* (((symbolp hook)) |
| 1393 | (result (funcall which-func command))) | 1393 | (which-func (get hook 'eshell-which-function)) |
| 1394 | (throw 'found result)))) | 1394 | (result (funcall which-func command))) |
| 1395 | (eshell-plain-command--which name))) | 1395 | (throw 'found result)))) |
| 1396 | (error (eshell-error (format "which: %s\n" (cadr error))))))) | 1396 | (eshell-plain-command--which name))) |
| 1397 | (error (eshell-error (format "which: %s\n" (cadr error))) | ||
| 1398 | (setq not-found t)))) | ||
| 1399 | (when not-found (eshell-set-exit-info 1)))) | ||
| 1397 | 1400 | ||
| 1398 | (put 'eshell/which 'eshell-no-numeric-conversions t) | 1401 | (put 'eshell/which 'eshell-no-numeric-conversions t) |
| 1399 | 1402 | ||