octacian 5d59142b10 OctOS: Improve error handling
Commands run and code called with the `lua` command would not throw an error if it was unsucessful.
2017-03-28 16:45:27 -07:00

30 lines
500 B
Lua

local input = get_attr("input"):split(" ")
local bin = get_userdata("bin")
if input[1] ~= "" then
print(get_attr("input"), false)
local binentry = bin[input[1]]
if binentry then
-- Remove first param
table.remove(input, 1)
local ok, res = fs.run(binentry.exec, input)
if not ok then
print("Error: "..res)
end
else
print(input[1]..": command not found")
end
print(get_os("prefix"))
-- Clear input
set_input("")
-- Refresh view
refresh()
end