From 38cd4eef4d720bccf8f318eb83bf95c19d69bf73 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 30 Jul 2022 19:56:10 -0700 Subject: 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. --- stdlib/path-test.tl | 38 ++++++++++++++++++++------------------ 1 file 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 -- cgit v1.2.3