diff options
Diffstat (limited to 'lisp/progmodes/executable.el')
| -rw-r--r-- | lisp/progmodes/executable.el | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el index 21f894753a1..b301d84d144 100644 --- a/lisp/progmodes/executable.el +++ b/lisp/progmodes/executable.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; executable.el --- base functionality for executable interpreter scripts -*- byte-compile-dynamic: t -*- | 1 | ;;; executable.el --- base functionality for executable interpreter scripts -*- byte-compile-dynamic: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1994, 1995, 1996, 2000, 2003 by Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1994, 1995, 1996, 2000, 2003, 2004 by Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Daniel Pfeiffer <occitan@esperanto.org> | 5 | ;; Author: Daniel Pfeiffer <occitan@esperanto.org> |
| 6 | ;; Keywords: languages, unix | 6 | ;; Keywords: languages, unix |
| @@ -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. | ||
| 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)))) | ||
| 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. |
| 146 | Return nil if COMMAND is not found anywhere in `exec-path'." | 171 | Return nil if COMMAND is not found anywhere in `exec-path'." |