OC-PsychOS/modules/lib/shutil.lua

27 lines
492 B
Lua
Raw Normal View History

local shutil = {}
function shutil.genenv()
local et = os.genenv()
for k,v in pairs(shutil) do
if k ~= "genenv" then
et[k] = v
end
end
return et
end
function loadfile(fn)
local f=io.open(fn,"rb")
local S=f:read("*a")
f:close()
return load(S,"=("..fn..")","bt",os.genenv())
end
function run(fn,...)
2017-08-04 17:44:37 +10:00
local r = {pcall(loadfile(fn),...)}
if r[1] == true then
table.remove(r,1)
end
print(table.unpack(r))
end
function srun(fn,...)
spawn(fn,print(pcall(loadfile(fn),...)))
end