2019-07-14 06:52:56 -04:00
|
|
|
print(pcall(function()
|
2018-11-02 12:05:41 -04:00
|
|
|
local shenv = {}
|
2019-01-09 00:23:30 -05:00
|
|
|
function shenv.quit()
|
|
|
|
os.setenv("run",nil)
|
|
|
|
end
|
2019-11-05 22:28:40 -05:00
|
|
|
shenv.cd = os.chdir
|
2019-07-27 22:45:38 -04:00
|
|
|
setmetatable(shenv,{__index=function(_,k)
|
|
|
|
if _G[k] then
|
|
|
|
return _G[k]
|
|
|
|
elseif fs.exists("/boot/exec/"..k..".lua") then
|
2019-11-03 16:55:39 -05:00
|
|
|
--[[
|
2019-07-28 05:46:43 -04:00
|
|
|
local rqid = string.format("shell-%d",math.random(1,99999))
|
2019-07-27 22:45:38 -04:00
|
|
|
return function(...)
|
|
|
|
local tA = {...}
|
2019-07-28 05:46:43 -04:00
|
|
|
local pid = os.spawn(function() computer.pushSignal(rqid,pcall(loadfile("/boot/exec/"..k..".lua"),table.unpack(tA))) end,"/boot/exec/"..k..".lua")
|
|
|
|
local tE = {}
|
2019-07-27 22:45:38 -04:00
|
|
|
repeat
|
2019-07-28 05:46:43 -04:00
|
|
|
tE = {coroutine.yield()}
|
|
|
|
if tE[1] == rqid then
|
|
|
|
table.remove(tE,1)
|
2019-07-28 05:52:32 -04:00
|
|
|
if tE[1] == true then
|
|
|
|
table.remove(tE,1)
|
|
|
|
end
|
2019-07-28 05:46:43 -04:00
|
|
|
return table.unpack(tE)
|
|
|
|
end
|
2019-07-27 22:45:38 -04:00
|
|
|
until tTasks[pid] == nil
|
|
|
|
end
|
2019-11-03 16:55:39 -05:00
|
|
|
]]--
|
|
|
|
return loadfile("/boot/exec/"..k..".lua")
|
2019-07-27 22:45:38 -04:00
|
|
|
end
|
|
|
|
end})
|
2019-01-08 02:03:51 -05:00
|
|
|
print(_VERSION)
|
2019-01-09 00:23:30 -05:00
|
|
|
os.setenv("run",true)
|
|
|
|
while os.getenv("run") do
|
2019-01-08 02:03:51 -05:00
|
|
|
io.write((os.getenv("PWD") or _VERSION).."> ")
|
2018-11-02 12:05:41 -04:00
|
|
|
tResult = {pcall(load(io.read(),"shell","t",shenv))}
|
2019-01-08 02:03:51 -05:00
|
|
|
if tResult[1] == true then table.remove(tResult,1) end
|
2018-11-02 12:05:41 -04:00
|
|
|
for k,v in pairs(tResult) do
|
|
|
|
print(v)
|
|
|
|
end
|
|
|
|
end
|
2019-07-14 06:52:56 -04:00
|
|
|
end))
|