]> git.eshelyaron.com Git - emacs.git/commitdiff
(executable-command-find-posix-p):
authorRichard M. Stallman <rms@gnu.org>
Thu, 29 Jan 2004 17:53:17 +0000 (17:53 +0000)
committerRichard M. Stallman <rms@gnu.org>
Thu, 29 Jan 2004 17:53:17 +0000 (17:53 +0000)
New.  Check if find handles arguments Posix-style.

lisp/progmodes/executable.el

index 21f894753a1a2c6dbf4e0b6b86533428912183c6..4d12031588de96d3ad3208841ded334cb43c7b04 100644 (file)
@@ -140,6 +140,31 @@ See `compilation-error-regexp-alist'.")
 ;; The C function openp slightly modified would do the trick fine
 (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.