From: Michael Albinus Date: Tue, 25 Feb 2025 08:37:28 +0000 (+0100) Subject: Fix tramp-find-executable X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7d3ff2116519e1125ba380f349759abc371d01af;p=emacs.git Fix tramp-find-executable * lisp/net/tramp-sh.el (tramp-find-executable): Use "command -pv", it isbetter supported in different shells. (Bug#76521) (cherry picked from commit 53eec34da1bf2fb9381680734a99f3fb11225787) --- diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 080a74405d1..c78234e57a3 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -4098,25 +4098,23 @@ only in DIRLIST. Returns the absolute file name of PROGNAME, if found, and nil otherwise. This function expects to be in the right *tramp* buffer." - (with-current-buffer (tramp-get-connection-buffer vec) - (unless ignore-path - (setq dirlist (cons "$PATH" dirlist))) - (when ignore-tilde - ;; Remove all ~/foo directories from dirlist. - (let (newdl d) - (while dirlist - (setq d (car dirlist) - dirlist (cdr dirlist)) - (unless (char-equal ?~ (aref d 0)) - (setq newdl (cons d newdl)))) - (setq dirlist (nreverse newdl)))) - (tramp-send-command - vec (format "%s type -P %s 2>%s" - (if dirlist (concat "PATH=" (string-join dirlist ":")) "") - progname (tramp-get-remote-null-device vec))) - (goto-char (point-min)) - (when (search-forward-regexp "/" nil 'noerror) - (string-trim (buffer-substring (match-beginning 0) (point-max)))))) + (unless ignore-path + (setq dirlist (cons "$PATH" dirlist))) + (when ignore-tilde + ;; Remove all ~/foo directories from dirlist. + (let (newdl d) + (while dirlist + (setq d (car dirlist) + dirlist (cdr dirlist)) + (unless (char-equal ?~ (aref d 0)) + (setq newdl (cons d newdl)))) + (setq dirlist (nreverse newdl)))) + (when (tramp-send-command-and-check + vec (format "(unalias %s; %s command -pv %s)" + progname + (if dirlist (concat "PATH=" (string-join dirlist ":")) "") + progname)) + (string-trim (tramp-get-buffer-string (tramp-get-connection-buffer vec))))) ;; On hydra.nixos.org, the $PATH environment variable is too long to ;; send it. This is likely not due to PATH_MAX, but PIPE_BUF. We