summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-07-30 19:56:10 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-07-30 19:56:10 -0700
commit6f6ccfae165ad4a586429382925f6e4cdf5457a3 (patch)
tree637dcb5ec508feec84803a914d5b620f26880a47
parent01e1dc8af54375c50e2cf8889a58a781b42bcae3 (diff)
downloadtxr-6f6ccfae165ad4a586429382925f6e4cdf5457a3.tar.gz
txr-6f6ccfae165ad4a586429382925f6e4cdf5457a3.tar.bz2
txr-6f6ccfae165ad4a586429382925f6e4cdf5457a3.zip
path-components-safe: proc tests only on Linux.
* stdlib/path-test.tl (safe-abs-path): If (uname) doesn't report Linux, then define this function in a way that it always returns true. We do this by making the name an alias for the tf function.
-rw-r--r--stdlib/path-test.tl38
1 files changed, 20 insertions, 18 deletions
diff --git a/stdlib/path-test.tl b/stdlib/path-test.tl
index ceb83c3a..02fd0d55 100644
--- a/stdlib/path-test.tl
+++ b/stdlib/path-test.tl
@@ -180,24 +180,26 @@
(and (eql (logand st.mode sdir) sdir)
(zerop st.uid))))
-(defun safe-abs-path (comps)
- (flet ((digstr (s) [all s chr-isdigit]))
- (let ((safe t))
- (when-match ("proc" @(or @(digstr) "self") . @rest)
- (path-simplify comps)
- (match-case rest
- (@(or ("cwd" . @nil)
- ("root" . @nil)
- ("map_files" . @nil)
- ("fd" @(digstr) . @nil))
- (zap safe))
- (("task" @(digstr) . @trest)
- (match-case trest
- (@(or ("cwd" . @nil)
- ("root" . @nil)
- ("fd" @(digstr) . @nil))
- (zap safe))))))
- safe)))
+(if (starts-with "Linux" (uname).sysname)
+ (defun safe-abs-path (comps)
+ (flet ((digstr (s) [all s chr-isdigit]))
+ (let ((safe t))
+ (when-match ("proc" @(or @(digstr) "self") . @rest)
+ (path-simplify comps)
+ (match-case rest
+ (@(or ("cwd" . @nil)
+ ("root" . @nil)
+ ("map_files" . @nil)
+ ("fd" @(digstr) . @nil))
+ (zap safe))
+ (("task" @(digstr) . @trest)
+ (match-case trest
+ (@(or ("cwd" . @nil)
+ ("root" . @nil)
+ ("fd" @(digstr) . @nil))
+ (zap safe))))))
+ safe)))
+ (set (symbol-function 'safe-abs-path) (fun tf)))
(defun path-components-safe (path)
(if-native-windows