hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/gils
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-10-09 20:13:44 +0200
committerhachem <im@hachem.wtf>2026-10-09 20:13:44 +0200
commit2ae433bd20bb68b787c3dd92f635f6c820dcfcb9 (patch)
treef73c74d4d1c8ced97b6a7a7b6a55ca20beea9805 /gils
parent016a104cb4f2f99cdd3bec1f12ab188141376ca6 (diff)
fix: rework how paths work
Diffstat (limited to 'gils')
-rw-r--r--gils/gils.rv22
1 files changed, 21 insertions, 1 deletions
diff --git a/gils/gils.rv b/gils/gils.rv
index 2432890..289e547 100644
--- a/gils/gils.rv
+++ b/gils/gils.rv
@@ -38,7 +38,27 @@ global expand_path = fn(path) -> string do
path = "#{wd.path}#{slash}#{path}"
end
- return path
+ # collapse . and .. segments
+ const raw = path:split("/")
+ let parts = {}
+ for index in 0..raw:len() do
+ const seg = raw[index]
+ if seg == ".." do
+ if (parts:len() > 0)
+ parts:pop()
+ end else if seg != "" and seg != "." do
+ parts:push(seg)
+ end
+ end
+
+ if (parts:len() == 0)
+ return "/"
+
+ let result = ""
+ for index in 0..parts:len() do
+ result = result ~ "/" ~ parts[index]
+ end
+ return result
end
fn run_script_path(path, label, ctx) -> bool do