On Wed, Nov 23, 2011 at 10:03 PM,
<rixed@happyleptic.org> wrote:
-[ Wed, Nov 23, 2011 at 08:28:56PM +0800, Nala Ginrut ]----
> I think there's no such a given function in Guile to do this.
> But you can make it in a easy way in Guile:
> (catch 'system-error
> (lambda () (execlp "asdfasdf"))
> (lambda (k . e)
> (format #t "oh no~%~")))
>
> PS: Maybe you need #f instead of "format" according to your letter. ;-)
It's my understanding that the OP does not want to actually run the
program but merely knows either the file is in the PATH or not.
I guess some-function would be something like :
(use-modules (srfi srfi-1)) ; for any
(define (in-path? f)
(let ((path (string-split (getenv "PATH") #\:))
(make-absolute (lambda (path) (string-append path "/" f))))
(any file-exists? (map make-absolute path))))
Well, I realized that Paul want this some-function to detect whether file can be executed.
[quote] My question is then, *is* there a way to determine if a string is executable? (And if so, how? :-) .[/quote]
I confess that I didn't quite understand this question.
So I guess there're two alternatives:
1. He needs some-function to detect each file in a path an return the result or #f;
2. He needs some-function to handle the error if a certain string can not be executed.