控制台sudo模式开启后用#执行命令就可以,不需要一直输入sudo了
This commit is contained in:
@@ -638,24 +638,8 @@ local commands={}do
|
|||||||
commands.sudo={
|
commands.sudo={
|
||||||
code=function(code)
|
code=function(code)
|
||||||
if sudomode then
|
if sudomode then
|
||||||
--Filter ""
|
log{C.Y,"You are already in the sudo mode, use # to run any lua code"}
|
||||||
if #code==0 then log{C.R,"Usage: sudo [Lua code]"}return end
|
log{C.Y,"已经进入最高权限模式了, 请使用 # 执行任意lua代码"}
|
||||||
|
|
||||||
--Check Syntax error
|
|
||||||
local func,errmsg=loadstring(code)
|
|
||||||
if errmsg then log{C.R,errmsg}return end
|
|
||||||
|
|
||||||
--Run code
|
|
||||||
local success,result=pcall(func)
|
|
||||||
if success then
|
|
||||||
if result~=nil then
|
|
||||||
log{C.lG,">> "..tostring(result)}
|
|
||||||
else
|
|
||||||
log{C.lG,"done"}
|
|
||||||
end
|
|
||||||
else
|
|
||||||
log{C.R,result}
|
|
||||||
end
|
|
||||||
elseif code=="7126"then
|
elseif code=="7126"then
|
||||||
sudomode=true
|
sudomode=true
|
||||||
log{C.Y,"* SUDO MODE ON, DO NOT RUN ANY CODE YOU DON'T UNDERSTAND *"}
|
log{C.Y,"* SUDO MODE ON, DO NOT RUN ANY CODE YOU DON'T UNDERSTAND *"}
|
||||||
@@ -912,13 +896,19 @@ function scene.keyDown(key)
|
|||||||
log{C.lC,"> "..input}
|
log{C.lC,"> "..input}
|
||||||
local code,err=loadstring(input:sub(2))
|
local code,err=loadstring(input:sub(2))
|
||||||
if code then
|
if code then
|
||||||
setfenv(code,userG)
|
if not sudomode then setfenv(code,userG)end
|
||||||
code,err=pcall(code)
|
local success,result=pcall(code)
|
||||||
if not code then
|
if success then
|
||||||
log{C.R,"[ERR] ",C.Z,err}
|
if result~=nil then
|
||||||
|
log{C.lG,">> "..tostring(result)}
|
||||||
|
else
|
||||||
|
log{C.lG,"done"}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
log{C.R,result}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log{C.R,"[SYNTAX ERR] ",C.Z,err}
|
log{C.R,"[SyntaxErr] ",C.R,err}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
--Execute builtin command
|
--Execute builtin command
|
||||||
|
|||||||
Reference in New Issue
Block a user