From 6713f48361ecab50cfdbc5d2cd21a76b0d02c840 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 7 Aug 2021 15:27:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A7=E5=88=B6=E5=8F=B0su?= =?UTF-8?q?do=E5=91=BD=E4=BB=A4=E7=9A=84=E4=BA=A4=E4=BA=92=20close=20#171?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/app_console.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/parts/scenes/app_console.lua b/parts/scenes/app_console.lua index 14b2fbbe..2bc6de50 100644 --- a/parts/scenes/app_console.lua +++ b/parts/scenes/app_console.lua @@ -638,7 +638,15 @@ local commands={}do commands.sudo={ code=function(code) if sudomode then - local success,result=pcall(loadstring(code)) + --Filter "" + if #code==0 then log{C.R,"Usage: sudo [Lua code]"}return end + + --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)}