diff options
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/doc-syms.tl | 1 | ||||
-rw-r--r-- | stdlib/path-test.tl | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/stdlib/doc-syms.tl b/stdlib/doc-syms.tl index cce921a1..90d8bd07 100644 --- a/stdlib/doc-syms.tl +++ b/stdlib/doc-syms.tl @@ -1372,6 +1372,7 @@ ("path-read-writable-to-me-p" "N-028A5109") ("path-readable-to-me-p" "N-02933008") ("path-same-object" "N-0103E27B") + ("path-search" "N-01AB7247") ("path-sep-chars" "N-03985DE5") ("path-setgid-p" "N-02FBA677") ("path-setuid-p" "N-02FBA677") diff --git a/stdlib/path-test.tl b/stdlib/path-test.tl index fb132f7f..b3483962 100644 --- a/stdlib/path-test.tl +++ b/stdlib/path-test.tl @@ -185,3 +185,16 @@ (casequal ent (("." "..")) (t (return nil)))))))) + +(defun path-search (name : (path (getenv "PATH"))) + (if (empty name) + nil + (let ((pcomp (if (listp path) + path + (spl (if (starts-with "CYGNAL" (uname).sysname) #\; #\:) + path)))) + (each ((pc pcomp)) + (if (nequal pc "") + (let ((st (ignerr (stat (path-cat pc name))))) + (if (and st (path-executable-to-me-p st) (path-file-p st)) + (return st.path)))))))) |