diff options
author | Richard M. Stallman <rms@gnu.org> | 2004-01-29 17:53:17 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2004-01-29 17:53:17 +0000 |
commit | 14768716428c6fbf938c8f40bc6352da0eccdfe6 (patch) | |
tree | 0c36414273c2dfcb8f4e3762c413b8d4bd2be420 /lisp/progmodes/executable.el | |
parent | 05e72590a1f0bdb9bd931360bcb698a0d60549a7 (diff) | |
download | emacs-14768716428c6fbf938c8f40bc6352da0eccdfe6.tar.gz |
(executable-command-find-posix-p):
New. Check if find handles arguments Posix-style.
Diffstat (limited to 'lisp/progmodes/executable.el')
-rw-r--r-- | lisp/progmodes/executable.el | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el index 21f894753a1..4d12031588d 100644 --- a/lisp/progmodes/executable.el +++ b/lisp/progmodes/executable.el @@ -141,6 +141,31 @@ See `compilation-error-regexp-alist'.") (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'." |