wrote a new version of luash, lush, which is just nicer to use.
This commit is contained in:
parent
b9916c2b13
commit
0bb3921781
@ -28,7 +28,7 @@ libwrap sha modules/lib/sha256.lua
|
||||
modules/net/net-ext.lua
|
||||
modules/applications/login.lua
|
||||
modules/applications/genkernel.lua
|
||||
fwrap luash exec/luash.lua
|
||||
fwrap luash exec/lush.lua
|
||||
fwrap skex exec/skex2.lua
|
||||
fwrap nshd exec/nshd.lua
|
||||
fwrap nsh exec/nsh.lua
|
||||
|
@ -25,7 +25,7 @@ alias shutil.mv fs.mv
|
||||
modules/lib/sha256.lua
|
||||
modules/net/net-ext.lua
|
||||
modules/applications/login.lua
|
||||
fwrap luash exec/luash.lua
|
||||
fwrap luash exec/lush.lua
|
||||
modules/applications/genkernel.lua
|
||||
fwrap skex exec/skex2.lua
|
||||
fwrap nshd exec/nshd.lua
|
||||
|
@ -23,7 +23,7 @@ alias shutil.mv fs.mv
|
||||
libwrap sha modules/lib/sha256.lua
|
||||
modules/net/net-ext.lua
|
||||
modules/applications/login.lua
|
||||
fwrap luash exec/luash.lua
|
||||
fwrap luash exec/lush.lua
|
||||
modules/applications/genkernel.lua
|
||||
modules/util/fs-automount.lua
|
||||
modules/setup.lua
|
||||
|
52
exec/lush.lua
Normal file
52
exec/lush.lua
Normal file
@ -0,0 +1,52 @@
|
||||
local tA = {...}
|
||||
local si = tA[1]
|
||||
spawn("lua shell", function() print(pcall(function()
|
||||
os.setenv("sI",si)
|
||||
_ENV = shutil.genenv()
|
||||
coroutine.yield()
|
||||
log(pcall(login))
|
||||
|
||||
print(_VERSION)
|
||||
local function shexec(line)
|
||||
local words = {}
|
||||
for w in line:gmatch("%S+") do table.insert(words,w) end
|
||||
local pth = os.getenv("PATH") or "."
|
||||
for d in pth:gmatch("[^:]+") do
|
||||
local prg = words[1]
|
||||
_,lex = pcall(fs.exists,d.."/"..prg..".lua")
|
||||
_,nex = pcall(fs.exists,d.."/"..prg)
|
||||
if lex or nex then
|
||||
table.remove(words,1)
|
||||
end
|
||||
if lex then
|
||||
return pcall(loadfile(d.."/"..prg..".lua",table.unpack(words)))
|
||||
elseif nex then
|
||||
return pcall(loadfile(d.."/"..prg,table.unpack(words)))
|
||||
end
|
||||
end
|
||||
if _ENV[words[1]] then
|
||||
local prg = table.remove(words,1)
|
||||
local r={pcall(_ENV[prg],table.unpack(words))}
|
||||
if r[1] == true then
|
||||
table.remove(r,1)
|
||||
end
|
||||
return table.unpack(r)
|
||||
end
|
||||
if line:sub(1,1) == "=" then
|
||||
line="return "..line:sub(2)
|
||||
end
|
||||
local r={pcall(load(line,"shell","bt",_ENV))}
|
||||
return table.unpack(r)
|
||||
end
|
||||
while true do
|
||||
local didexec = false
|
||||
write((os.getenv("PWD") or "").."> ")
|
||||
local inp=readln()
|
||||
if not inp then break end
|
||||
local rt = {shexec(inp)}
|
||||
if rt[1] == true then
|
||||
table.remove(rt,1)
|
||||
end
|
||||
print(table.unpack(rt))
|
||||
end
|
||||
end)) end)
|
Loading…
Reference in New Issue
Block a user