blob: f79865963745ee92a8be6c293577555c5c966627 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
|