diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-06-29 06:52:38 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-06-29 06:52:38 -0700 |
commit | 7a9786b4154f939e60bb2923b8b90a81f38e20ad (patch) | |
tree | bed321bd031292edcb41fd809d303e50e5e79d7e /stdlib | |
parent | 71d939c17417180c2d6c77032fece5bdef7181d1 (diff) | |
download | txr-7a9786b4154f939e60bb2923b8b90a81f38e20ad.tar.gz txr-7a9786b4154f939e60bb2923b8b90a81f38e20ad.tar.bz2 txr-7a9786b4154f939e60bb2923b8b90a81f38e20ad.zip |
New function: path-search.
* lisplib.c (path_test_set_entries): Autoload on path-search.
* stdlib/path-test.tl (path-search): New function.
* tests/018/path-test.tl: New file.
* txr.1: Documented.
* stdlib/doc-lookup.tl: Updated.
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)))))))) |