1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-30 23:23:03 +00:00

support open os command line programs

This commit is contained in:
kepler155c@gmail.com
2019-04-07 10:09:47 -04:00
parent 737ac095de
commit 4f9bd8eb0f
9 changed files with 146 additions and 65 deletions

View File

@@ -123,23 +123,25 @@ function multishell.openTab(tab)
local routine = kernel.newRoutine(tab)
routine.co = coroutine.create(function()
local result, err, stacktrace
local result, err
if tab.fn then
result, err = Util.runFunction(routine.env, tab.fn, table.unpack(tab.args or { } ))
elseif tab.path then
result, err, stacktrace = xprun(routine.env, tab.path, table.unpack(tab.args or { } ))
result, err = xprun(routine.env, tab.path, table.unpack(tab.args or { } ))
else
err = 'multishell: invalid tab'
end
if not result and err and err ~= 'Terminated' then
if err then
if not result and err and err ~= 'Terminated' or (err and err ~= 0) then
tab.terminal.setBackgroundColor(colors.black)
if tonumber(err) then
tab.terminal.setTextColor(colors.orange)
print('Process exited with error code: ' .. err)
elseif err then
printError(tostring(err))
if stacktrace then -- alternatively log stack to _debug
--print('\n' .. stacktrace)
end
end
tab.terminal.setTextColor(colors.white)
print('\nPress enter to close')
routine.isDead = true
routine.hidden = false