diff options
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 |
