From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: jari.aalto@poboxes.com (Jari Aalto+mail.linux) Newsgroups: gmane.emacs.bugs Subject: Re: [patch] 21.3 executable.el - New func executable-command-find-unix-p Date: Tue, 03 Feb 2004 18:38:15 +0200 Organization: Private Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: <65eoktjc.fsf@blue.sea.net> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1075826151 26311 80.91.224.253 (3 Feb 2004 16:35:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 3 Feb 2004 16:35:51 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 03 17:35:38 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ao3WU-0008Qi-00 for ; Tue, 03 Feb 2004 17:35:38 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Ao3T1-0001OB-1E for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Feb 2004 11:32:03 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1Ao3Pa-0000J3-BA for bug-gnu-emacs@prep.ai.mit.edu; Tue, 03 Feb 2004 11:28:30 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1Ao3P1-00008d-Eq for bug-gnu-emacs@prep.ai.mit.edu; Tue, 03 Feb 2004 11:28:26 -0500 Original-Received: from [193.4.58.12] (helo=horus.isnic.is) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1Ao3OF-0008DX-SF for bug-gnu-emacs@prep.ai.mit.edu; Tue, 03 Feb 2004 11:27:11 -0500 Original-Received: from smtp34.kolumbus.fi (smtp34.kolumbus.fi [193.229.0.38]) by horus.isnic.is (8.12.9p2/8.12.9/isnic) with ESMTP id i13GQucs008049 for ; Tue, 3 Feb 2004 16:26:56 GMT (envelope-from news@phys-news1.kolumbus.fi) Original-Received: from news.kolumbus.fi (news.kolumbus.fi [193.229.0.31]) by smtp34.kolumbus.fi (8.12.10/8.12.4) with ESMTP id i13GQmWA016351 for ; Tue, 3 Feb 2004 18:26:49 +0200 (EET) Original-Received: (from news@localhost) by news.kolumbus.fi (8.11.6+Sun/8.11.6) id i13GQmE04437 for gnu-emacs-bug@moderators.isc.org; Tue, 3 Feb 2004 18:26:48 +0200 (EET) Original-To: gnu-emacs-bug@moderators.isc.org Original-Path: not-for-mail Original-Newsgroups: gnu.emacs.bug Original-Lines: 112 Original-NNTP-Posting-Host: a110t7.elisa.omakaista.fi Original-X-Trace: phys-news1.kolumbus.fi 1075825607 4153 81.197.3.110 (3 Feb 2004 16:26:47 GMT) Original-X-Complaints-To: abuse@kolumbus.fi Original-NNTP-Posting-Date: Tue, 3 Feb 2004 16:26:47 +0000 (UTC) User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (windows-nt) (i386-msvc-nt5.0.2195) Cancel-Lock: sha1:BTssjSWBjstzJdPLmsxBumpxhAs= X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:6870 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:6870 * Wed 2004-01-28 jari.aalto poboxes.com (Jari Aalto+mail.linux) gnu.emacs.bug * | | Right. The message is a good indication of Unix find(1) as well. Here | fix for the previous code. Also added couple of options more like -print. | | | 2004-01-28 Jari Aalto | | * progmodes/executable.el (executable-command-find-unix-p): | Check basic find which does not support -maxdepth. | Return find(1) type: 'gnu, t or nil. And a little more error checking added. This patch should be aplied after the previous on {See Message ID-reference above). 2004-02-03 Tue Jari Aalto poboxes.com> * progmodes/executable.el (executable-command-find-test-data): New. (executable-command-find-unix-p): Improved error checking. Moved logic to `executable-command-find-test-data'. Index: executable.el =================================================================== RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/progmodes/executable.el,v retrieving revision 1.3 retrieving revision 1.5 diff -u -IId: -b -w -u -r1.3 -r1.5 --- executable.el 28 Jan 2004 20:56:16 -0000 1.3 +++ executable.el 3 Feb 2004 16:34:18 -0000 1.5 @@ -52,7 +52,8 @@ ;;; Code: -(autoload 'find-if "cl-seq") +(eval-when-compile + (require 'cl)) (defgroup executable nil "Base functionality for executable interpreter scripts" @@ -145,6 +146,27 @@ '(".exe" ".com" ".bat" ".cmd" ".btm" "") '(""))) +(defun executable-command-find-test-data () + "Return list (DIR FILE) to search from randomly picked directory." + (let (dir file) + (dolist (elt (append load-path (list (getenv "TEMP") + (getenv "TMP") + "/tmp" + "c:/temp"))) + (when (and (stringp elt) + ;; load-path may contain stale directories. + (file-directory-p elt) + (setq dir elt) + (setq file (find-if + (lambda (x) + ;; Filter directories . and .. + (and (not (string-match "^\\.\\.?$" x)) + (not (file-directory-p x)))) + (directory-files dir 'full)))) + (return))) + (when (and dir file) + (list dir (file-name-nondirectory file))))) + ;;;###autoload (defun executable-command-find-unix-p (&optional program) "Check if command 'find' is Unix type program. @@ -153,15 +175,11 @@ Return: 'gnu for GNU find(1) t for other unix compatible find(1)" - ;; Pick file to search from location we know - (let* ((dir (car load-path)) - (file (find-if - (lambda (x) - ;; Filter directories . and .. - (and (not (string-match "^\\.\\.?$" x)) - ;; load-path may contain stale directories. - (file-directory-p x))) - (directory-files dir)))) + (multiple-value-bind (dir file) + (executable-command-find-test-data) + (unless file + ;; This is better message than cryptic failure in: "-name" file + (error "executable: Cannot find suitable file to test.")) (with-temp-buffer (call-process (or program "find") @@ -173,17 +191,18 @@ file "-mount" "-print" - ;; GNU find(1) understands this - ;; Solaris 8 (SunOS 5.8), both + ;; - GNU find(1) understands -maxdepth + ;; - Solaris 8 (SunOS 5.8), both ;; /usr/bin/find and /usr/xpg4/bin/find report ;; reports "find: bad option -maxdepth" + ;; - W2k reports "FIND: Parameter format not correct\" "-maxdepth" "1") (goto-char (point-min)) (cond ((search-forward file nil t) 'gnu) - ((search-forward "find: bad option -maxdepth") + ((search-forward "find: bad option -maxdepth" nil t) t))))) ;;;###autoload