2017-09-13 13:37:26 +10:00
|
|
|
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
|
2017-08-04 07:08:44 +10:00
|
|
|
function loadfile(fn)
|
|
|
|
local f=io.open(fn,"rb")
|
|
|
|
local S=f:read("*a")
|
|
|
|
f:close()
|
2017-08-27 03:52:54 +10:00
|
|
|
return load(S,"=("..fn..")","bt",os.genenv())
|
2017-08-04 07:08:44 +10:00
|
|
|
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))
|
2017-08-04 07:08:44 +10:00
|
|
|
end
|
|
|
|
function srun(fn,...)
|
|
|
|
spawn(fn,print(pcall(loadfile(fn),...)))
|
|
|
|
end
|