-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkfifo.lua
More file actions
22 lines (22 loc) · 801 Bytes
/
mkfifo.lua
File metadata and controls
22 lines (22 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
local filesystem = require "system.filesystem"
local util = require "system.util"
local args = assert(util.argparse({m = true}, ...))
local function setmode(file)
local stat = filesystem.stat(file, true)
local oct = tonumber(args.m, 8)
if oct then
filesystem.chmod(file, stat.owner, bit32.band(bit32.rshift(oct, 6), 7))
filesystem.chmod(file, nil, bit32.band(oct, 7))
else
for perm in args.m:gmatch "[^,]+" do
local user, arg = perm:match "^([^%+%-=]*)([%+%-=][rwxs]+)$"
if not user then error("chmod: invalid mode: " .. perm) end
if user == "" then user = nil end
filesystem.chmod(file, user, arg)
end
end
end
for _, v in ipairs(args) do
filesystem.mkfifo(v)
if args.m then setmode(v) end
end