hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/gils/chmod.rv
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-10-21 06:45:53 +0200
committerhachem <im@hachem.wtf>2026-10-21 06:45:53 +0200
commit6f8e692be1c196113b91ad1986a00c9d6f6f0e48 (patch)
tree642bf354c1eacf3e67cdb3d41437586dfe44e4c0 /gils/chmod.rv
parent306e9cb38e3922093708dfbbaf12979edff2b788 (diff)
feat: user stuff like perms etc..HEADmain
Diffstat (limited to 'gils/chmod.rv')
-rw-r--r--gils/chmod.rv23
1 files changed, 23 insertions, 0 deletions
diff --git a/gils/chmod.rv b/gils/chmod.rv
new file mode 100644
index 0000000..f798659
--- /dev/null
+++ b/gils/chmod.rv
@@ -0,0 +1,23 @@
+# chmod <octal> <path
+# ill do the other things later
+
+fn parse_octal(text) -> num do
+ let value = 0
+ for index in 0..text:len() do
+ const code = text[index]:ascii()
+ if (code >= 48 and code <= 55)
+ value = value * 8 + (code - 48)
+ end
+ return value
+end
+
+const context = env.ctx
+
+if context.argv:len() < 3 do
+ fail("usage: chmod <octal> <path>\n")
+end else do
+ const mode = parse_octal(context.argv[1])
+ const path = expand_path(context.argv[2])
+ if (fs:chmod(path, mode) == :false)
+ fail("chmod: #{path}: no such file\n")
+end