Answers:
@Sigma的答案是一个好的开始,但是它不会按可执行性进行筛选,也不允许多余的后缀。例如,在Windows上,如果那是您的路径,则运行a
可以调用a.exe
。
因此使用executable-find
; 如果您好奇的话,这是定义(摘自Emacs的资料):
(defun executable-find (command)
"Search for COMMAND in `exec-path' and return the absolute file name.
Return nil if COMMAND is not found anywhere in `exec-path'."
;; Use 1 rather than file-executable-p to better match the behavior of
;; call-process.
(locate-file command exec-path exec-suffixes 1))
executable-find
你在找什么?