diff options
| author | hachem <im@hachem.wtf> | 2026-10-21 06:45:53 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-10-21 06:45:53 +0200 |
| commit | 6f8e692be1c196113b91ad1986a00c9d6f6f0e48 (patch) | |
| tree | 642bf354c1eacf3e67cdb3d41437586dfe44e4c0 /gils/chmod.rv | |
| parent | 306e9cb38e3922093708dfbbaf12979edff2b788 (diff) | |
Diffstat (limited to 'gils/chmod.rv')
| -rw-r--r-- | gils/chmod.rv | 23 |
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 |
