2017-09-13 12:52:03 +10:00
|
|
|
local tA = {...}
|
2017-09-13 13:45:24 +10:00
|
|
|
local si = tA[1]
|
2017-07-30 19:12:10 +10:00
|
|
|
spawn("lua shell",function()
|
2017-09-26 13:57:00 +10:00
|
|
|
os.setenv("sI",si)
|
2017-09-13 13:36:56 +10:00
|
|
|
_ENV = shutil.genenv()
|
2017-09-09 21:26:29 +10:00
|
|
|
coroutine.yield()
|
2017-09-14 15:12:00 +10:00
|
|
|
log(pcall(login))
|
2017-09-05 19:42:56 +10:00
|
|
|
print(_VERSION)
|
2017-07-30 19:12:10 +10:00
|
|
|
while true do
|
2017-07-31 12:10:45 +10:00
|
|
|
write((os.getenv("PWD") or "").."> ")
|
2017-08-01 16:38:43 +10:00
|
|
|
local inp=readln()
|
2017-09-05 19:08:24 +10:00
|
|
|
if not inp then break end
|
2017-08-04 17:44:37 +10:00
|
|
|
if inp:sub(1,1) == "!" then
|
|
|
|
local pth = os.getenv("PATH") or "."
|
|
|
|
local s,ptt = inp:sub(2), {}
|
|
|
|
for w in s:gmatch("%S+") do table.insert(ptt,w) end
|
|
|
|
local prg = table.remove(ptt,1)
|
|
|
|
for d in pth:gmatch("[^:]+") do
|
|
|
|
_,lex = pcall(fs.exists,d.."/"..prg..".lua")
|
|
|
|
_,nex = pcall(fs.exists,d.."/"..prg)
|
|
|
|
if lex then
|
|
|
|
run(d.."/"..prg..".lua",table.unpack(ptt))
|
|
|
|
break
|
|
|
|
elseif nex then
|
|
|
|
run(d.."/"..prg,table.unpack(ptt))
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif inp:sub(1,1) == "$" then
|
|
|
|
local s,ptt = inp:sub(2), {}
|
|
|
|
for w in s:gmatch("%S+") do table.insert(ptt,w) end
|
|
|
|
local prg = table.remove(ptt,1)
|
|
|
|
local r={pcall(_ENV[prg],table.unpack(ptt))}
|
|
|
|
if r[1] == true then
|
|
|
|
table.remove(r,1)
|
|
|
|
end
|
|
|
|
print(table.unpack(r))
|
|
|
|
else
|
|
|
|
if inp:sub(1,1) == "=" then
|
|
|
|
inp="return "..inp:sub(2)
|
|
|
|
end
|
2017-09-14 14:09:16 +10:00
|
|
|
local r={pcall(load(inp,"shell","bt",_ENV))}
|
2017-08-04 17:44:37 +10:00
|
|
|
if r[1] == true then
|
|
|
|
table.remove(r,1)
|
|
|
|
end
|
|
|
|
print(table.unpack(r))
|
|
|
|
end
|
2017-07-30 19:12:10 +10:00
|
|
|
end
|
2017-09-26 13:57:00 +10:00
|
|
|
end)
|