Mercurial > emacs
comparison lisp/progmodes/executable.el @ 53749:fef39a2085e4
(executable-command-find-posix-p):
New. Check if find handles arguments Posix-style.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Thu, 29 Jan 2004 17:53:17 +0000 |
| parents | 695cf19ef79e |
| children | 11ae9146993f |
comparison
equal
deleted
inserted
replaced
| 53748:c7884bc3f88f | 53749:fef39a2085e4 |
|---|---|
| 137 "Alist of regexps used to match script errors. | 137 "Alist of regexps used to match script errors. |
| 138 See `compilation-error-regexp-alist'.") | 138 See `compilation-error-regexp-alist'.") |
| 139 | 139 |
| 140 ;; The C function openp slightly modified would do the trick fine | 140 ;; The C function openp slightly modified would do the trick fine |
| 141 (defvaralias 'executable-binary-suffixes 'exec-suffixes) | 141 (defvaralias 'executable-binary-suffixes 'exec-suffixes) |
| 142 | |
| 143 ;;;###autoload | |
| 144 (defun executable-command-find-posix-p (&optional program) | |
| 145 "Check if PROGRAM handles arguments Posix-style. | |
| 146 If 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)))) | |
| 142 | 167 |
| 143 ;;;###autoload | 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. |
| 146 Return nil if COMMAND is not found anywhere in `exec-path'." | 171 Return nil if COMMAND is not found anywhere in `exec-path'." |
