/usr/lib/s9fes/search-path.scm is in scheme9 2010.11.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2010
; See the LICENSE file of the S9fES package for terms of use
;
; (search-path string1 string2) ==> string | #f
;
; Search the Unix search path STRING2 for the executable STRING1. Return
; the full path of the first executable found or #F if not executable
; named STRING1 can be found in the given path.
; STRING2 is a colon-separated list of paths, e.g.:
;
; "/bin:/usr/bin:/usr/local/bin"
;
; SEARCH-PATH uses ACCESS with mode ACCESS-X-OK to check whether a
; file is executable.
;
; (Example): (search-path "vi" "/bin:/usr/bin") ==> "/usr/bin/vi"
(require-extension sys-unix)
(load-from-library "string-split.scm")
(define (search-path file path)
(let loop ((path (string-split #\: path)))
(cond ((null? path)
#f)
((let ((loc (string-append (car path) "/" file)))
(and (sys:access loc sys:access-x-ok)
loc))
=> (lambda (x) x))
(else
(loop (cdr path))))))
|