* [patch] 21.3 executable.el - New func executable-command-find-unix-p
@ 2004-01-27 13:02 Jari Aalto+mail.linux
0 siblings, 0 replies; 4+ messages in thread
From: Jari Aalto+mail.linux @ 2004-01-27 13:02 UTC (permalink / raw)
I intend to fix grep-find, so we need common function to test
find(1) in compile.el and filecache.el. This would also benefit
igrep.el and other packages that depend on find(1).
2004-01-27 Tue Jari Aalto <jari.aalto <AT> poboxes.com>
* progmodes/executable.el (executable-command-find-unix-p):
New. Check if find(1) is Unix type command.
Index: executable.el
===================================================================
RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/progmodes/executable.el,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -IId: -b -w -u -r1.1 -r1.2
--- executable.el 26 Jun 2003 18:06:37 -0000 1.1
+++ executable.el 27 Jan 2004 12:58:49 -0000 1.2
@@ -144,6 +144,31 @@
'("")))
;;;###autoload
+(defun executable-command-find-unix-p (&optional program)
+ "Check if command 'find' is Unix type program.
+The patch to command can be assing in PROGRAM."
+ ;; 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.
Return nil if COMMAND is not found anywhere in `exec-path'."
--
http://tiny-tools.sourceforge.net/
Swatch @time http://www.mir.com.my/iTime/itime.htm
http://www.ryanthiessen.com/swatch/resources.htm
Use Licenses! http://www.linuxjournal.com/article.php?sid=6225
Which Licence? http://www.linuxjournal.com/article.php?sid=4825
OSI Licences http://www.opensource.org/licenses/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] 21.3 executable.el - New func executable-command-find-unix-p
[not found] <mailman.1449.1075209556.928.bug-gnu-emacs@gnu.org>
@ 2004-01-27 19:35 ` Kevin Rodgers
[not found] ` <mailman.1466.1075232226.928.bug-gnu-emacs@gnu.org>
1 sibling, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2004-01-27 19:35 UTC (permalink / raw)
Jari Aalto+mail.linux wrote:
> I intend to fix grep-find, so we need common function to test
> find(1) in compile.el and filecache.el. This would also benefit
> igrep.el and other packages that depend on find(1).
-maxdepth is a non-POSIX, GNU extension. On Solaris 8 (SunOS 5.8), both
/usr/bin/find and /usr/xpg4/bin/find report
find: bad option -maxdepth
> 2004-01-27 Tue Jari Aalto <jari.aalto <AT> poboxes.com>
>
> * progmodes/executable.el (executable-command-find-unix-p):
> New. Check if find(1) is Unix type command.
>
>
> Index: executable.el
> ===================================================================
> RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/progmodes/executable.el,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -IId: -b -w -u -r1.1 -r1.2
> --- executable.el 26 Jun 2003 18:06:37 -0000 1.1
> +++ executable.el 27 Jan 2004 12:58:49 -0000 1.2
> @@ -144,6 +144,31 @@
> '("")))
>
> ;;;###autoload
> +(defun executable-command-find-unix-p (&optional program)
> + "Check if command 'find' is Unix type program.
> +The patch to command can be assing in PROGRAM."
> + ;; 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.
> Return nil if COMMAND is not found anywhere in `exec-path'."
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] 21.3 executable.el - New func executable-command-find-unix-p
[not found] ` <mailman.1466.1075232226.928.bug-gnu-emacs@gnu.org>
@ 2004-01-28 21:00 ` Jari Aalto+mail.linux
[not found] ` <mailman.1524.1075323038.928.bug-gnu-emacs@gnu.org>
1 sibling, 0 replies; 4+ messages in thread
From: Jari Aalto+mail.linux @ 2004-01-28 21:00 UTC (permalink / raw)
* Tue 2004-01-27 Kevin Rodgers <ihs_4664 <AT> yahoo.com> gnu.emacs.bug
* <http://groups.google.com/groups?oi=djq&as_umsgid=%3Cmailman.1466.1075232226.928.bug-gnu-emacs@gnu.org>
| Jari Aalto+mail.linux wrote:
|
| > I intend to fix grep-find, so we need common function to test
| > find(1) in compile.el and filecache.el. This would also benefit
| > igrep.el and other packages that depend on find(1).
|
|
| -maxdepth is a non-POSIX, GNU extension. On Solaris 8 (SunOS 5.8), both
| /usr/bin/find and /usr/xpg4/bin/find report
|
| find: bad option -maxdepth
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 <jaalto@w2kpicasso>
* progmodes/executable.el (executable-command-find-unix-p):
Check basic find which does not support -maxdepth.
Return find(1) type: 'gnu, t or nil.
Index: executable.el
===================================================================
RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/progmodes/executable.el,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -IId: -b -w -u -r1.2 -r1.3
--- executable.el 27 Jan 2004 12:58:49 -0000 1.2
+++ executable.el 28 Jan 2004 20:56:16 -0000 1.3
@@ -52,6 +52,8 @@
;;; Code:
+(autoload 'find-if "cl-seq")
+
(defgroup executable nil
"Base functionality for executable interpreter scripts"
:group 'processes)
@@ -146,27 +148,43 @@
;;;###autoload
(defun executable-command-find-unix-p (&optional program)
"Check if command 'find' is Unix type program.
-The patch to command can be assing in PROGRAM."
+The path to command can be assing in PROGRAM.
+
+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 ..
- (not (string-match "^\\.\\.?$" x)))
+ (and (not (string-match "^\\.\\.?$" x))
+ ;; load-path may contain stale directories.
+ (file-directory-p x)))
(directory-files dir))))
(with-temp-buffer
- (call-process (or program "find")
+ (call-process
+ (or program "find")
nil
(current-buffer)
nil
dir
"-name"
file
+ "-mount"
+ "-print"
+ ;; GNU find(1) understands this
+ ;; Solaris 8 (SunOS 5.8), both
+ ;; /usr/bin/find and /usr/xpg4/bin/find report
+ ;; reports "find: bad option -maxdepth"
"-maxdepth"
"1")
(goto-char (point-min))
- (if (search-forward file nil t)
- t))))
+ (cond
+ ((search-forward file nil t)
+ 'gnu)
+ ((search-forward "find: bad option -maxdepth")
+ t)))))
;;;###autoload
(defun executable-find (command)
--
http://tiny-tools.sourceforge.net/
Swatch @time http://www.mir.com.my/iTime/itime.htm
http://www.ryanthiessen.com/swatch/resources.htm
Use Licenses! http://www.linuxjournal.com/article.php?sid=6225
Which Licence? http://www.linuxjournal.com/article.php?sid=4825
OSI Licences http://www.opensource.org/licenses/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] 21.3 executable.el - New func executable-command-find-unix-p
[not found] ` <mailman.1524.1075323038.928.bug-gnu-emacs@gnu.org>
@ 2004-02-03 16:38 ` Jari Aalto+mail.linux
0 siblings, 0 replies; 4+ messages in thread
From: Jari Aalto+mail.linux @ 2004-02-03 16:38 UTC (permalink / raw)
* Wed 2004-01-28 jari.aalto <AT> poboxes.com (Jari Aalto+mail.linux) gnu.emacs.bug
* <http://groups.google.com/groups?oi=djq&as_umsgid=%3Cmailman.1524.1075323038.928.bug-gnu-emacs@gnu.org>
|
| 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 <jaalto@w2kpicasso>
|
| * 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 <jari.aalto <AT> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-02-03 16:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-27 13:02 [patch] 21.3 executable.el - New func executable-command-find-unix-p Jari Aalto+mail.linux
[not found] <mailman.1449.1075209556.928.bug-gnu-emacs@gnu.org>
2004-01-27 19:35 ` Kevin Rodgers
[not found] ` <mailman.1466.1075232226.928.bug-gnu-emacs@gnu.org>
2004-01-28 21:00 ` Jari Aalto+mail.linux
[not found] ` <mailman.1524.1075323038.928.bug-gnu-emacs@gnu.org>
2004-02-03 16:38 ` Jari Aalto+mail.linux
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).