aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/executable.el
diff options
context:
space:
mode:
authorRichard M. Stallman2004-01-29 17:53:17 +0000
committerRichard M. Stallman2004-01-29 17:53:17 +0000
commit14768716428c6fbf938c8f40bc6352da0eccdfe6 (patch)
tree0c36414273c2dfcb8f4e3762c413b8d4bd2be420 /lisp/progmodes/executable.el
parent05e72590a1f0bdb9bd931360bcb698a0d60549a7 (diff)
downloademacs-14768716428c6fbf938c8f40bc6352da0eccdfe6.tar.gz
emacs-14768716428c6fbf938c8f40bc6352da0eccdfe6.zip
(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.el25
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'.")
141(defvaralias 'executable-binary-suffixes 'exec-suffixes) 141(defvaralias 'executable-binary-suffixes 'exec-suffixes)
142 142
143;;;###autoload 143;;;###autoload
144(defun executable-command-find-posix-p (&optional program)
145 "Check if PROGRAM handles arguments Posix-style.
146If PROGRAM is non-nil, use that instead of "find"."
147 ;; Pick file to search from location we know
148 (let* ((dir (car load-path))
149 (file (find-if
150 (lambda (x)
151 ;; Filter directories . and ..
152 (not (string-match "^\\.\\.?$" x)))
153 (directory-files dir))))
154 (with-temp-buffer
155 (call-process (or program "find")
156 nil
157 (current-buffer)
158 nil
159 dir
160 "-name"
161 file
162 "-maxdepth"
163 "1")
164 (goto-char (point-min))
165 (if (search-forward file nil t)
166 t))))
167
168;;;###autoload
144(defun executable-find (command) 169(defun executable-find (command)
145 "Search for COMMAND in `exec-path' and return the absolute file name. 170 "Search for COMMAND in `exec-path' and return the absolute file name.
146Return nil if COMMAND is not found anywhere in `exec-path'." 171Return nil if COMMAND is not found anywhere in `exec-path'."