tiny cleanup in shell for crashed scripts

remove unknown error message
This commit is contained in:
payonel 2020-05-14 20:18:38 -07:00
parent 310120df31
commit 5cb4dc5537
2 changed files with 6 additions and 3 deletions

View File

@ -5,6 +5,8 @@ local sh = require("sh")
local args = shell.parse(...) local args = shell.parse(...)
local t = type
shell.prime() shell.prime()
if #args == 0 then if #args == 0 then
@ -19,6 +21,7 @@ if #args == 0 then
if tty.getCursor() > 1 then if tty.getCursor() > 1 then
io.write("\n") io.write("\n")
end end
io.write("type:", t(type), '\n')
io.write(sh.expand(os.getenv("PS1") or "$ ")) io.write(sh.expand(os.getenv("PS1") or "$ "))
end end
tty.window.cursor = input_handler tty.window.cursor = input_handler
@ -31,8 +34,8 @@ if #args == 0 then
elseif command ~= "" then elseif command ~= "" then
--luacheck: globals _ENV --luacheck: globals _ENV
local result, reason = sh.execute(_ENV, command) local result, reason = sh.execute(_ENV, command)
if not result then if not result and reason then
io.stderr:write((reason and tostring(reason) or "unknown error") .. "\n") io.stderr:write(tostring(reason), "\n")
end end
end end
elseif command == nil then -- false only means the input was interrupted elseif command == nil then -- false only means the input was interrupted

View File

@ -198,7 +198,7 @@ function sh.execute(env, command, ...)
if type(words) ~= "table" then if type(words) ~= "table" then
return words, reason return words, reason
elseif #words == 0 then elseif #words == 0 then
return true, 0 return true
end end
-- MUST be table.pack for non contiguous ... -- MUST be table.pack for non contiguous ...