# HG changeset patch # User Richard M. Stallman # Date 1075398797 0 # Node ID fef39a2085e4791359e13b88813dd9667943fcbe # Parent c7884bc3f88f2b616a5b5eeca24938ef7deb3949 (executable-command-find-posix-p): New. Check if find handles arguments Posix-style. diff -r c7884bc3f88f -r fef39a2085e4 lisp/progmodes/executable.el --- a/lisp/progmodes/executable.el Thu Jan 29 17:22:15 2004 +0000 +++ b/lisp/progmodes/executable.el Thu Jan 29 17:53:17 2004 +0000 @@ -141,6 +141,31 @@ (defvaralias 'executable-binary-suffixes 'exec-suffixes) ;;;###autoload +(defun executable-command-find-posix-p (&optional program) + "Check if PROGRAM handles arguments Posix-style. +If PROGRAM is non-nil, use that instead of "find"." + ;; Pick file to search from location we know + (let* ((dir (car load-path)) + (file (find-if + (lambda (x) + ;; Filter directories . and .. + (not (string-match "^\\.\\.?$" x))) + (directory-files dir)))) + (with-temp-buffer + (call-process (or program "find") + nil + (current-buffer) + nil + dir + "-name" + file + "-maxdepth" + "1") + (goto-char (point-min)) + (if (search-forward file nil t) + t)))) + +;;;###autoload (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'."