made newer installer that does not require tar stuff
This commit is contained in:
1
prod/hysh/bin/chgrp
Normal file
1
prod/hysh/bin/chgrp
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b={R=false,help=false}local c={}for d,e in ipairs({...})do if e:sub(1,2)=="--"then local f=e:sub(3)if b[f]==nil then print(a..": unrecognized option '"..e.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;b[f]=true elseif e:sub(1,1)=="-"then for g=2,#e do local f=e:sub(g,g)if b[f]==nil then print(a..": invalid option '-"..f.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;b[f]=true end else table.insert(c,e)end end;if b.help then print("Usage: "..a.." [OPTION]... GROUP FILE...")print("Change the group of each FILE to GROUP.")print("GROUP may be a group name or numeric ID.")print("")print("Options:")print(" -R operate on files and directories recursively")print(" --help display this help and exit")return end;if#c<2 then print(a..": missing operand")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local h=c[1]local function i(j)local k=tonumber(j)if k then return k end;local l=syscall.getuidbyname and syscall.getuidbyname(j)if l then local m=syscall.getpasswd(l)if m then return m.gid end end;print(a..": invalid group: '"..j.."'")syscall.exit(1)end;local n=i(h)local function o(p)local q=syscall.stat(p)if not q then print(a..": cannot stat '"..p.."': no such file or directory")return false end;local r,s=pcall(syscall.chown,p,q.owner,n)if not r then local t=tostring(s)if t:find("EPERM")or t:find("EACCES")then t="operation not permitted (must be root)"elseif t:find("ENOENT")then t="no such file or directory"end;print(a..": cannot change group of '"..p.."': "..t)return false end;return true end;local function u(p)if not o(p)then return end;if syscall.type(p)=="directory"then local r,v=pcall(syscall.listdir,p)if r then for d,w in ipairs(v)do local x=p;if x:sub(-1)~="/"then x=x.."/"end;u(x..w)end end end end;local y=syscall.getcwd()local function z(A)if A:sub(1,1)~="/"then A=y.."/"..A end;return A end;local B=0;for g=2,#c do local p=z(c[g])if not syscall.exists(p)then print(a..": cannot access '"..c[g].."': No such file or directory")B=1 elseif b.R then u(p)else if not o(p)then B=1 end end end;syscall.exit(B)
|
||||
Reference in New Issue
Block a user