mirror of
https://github.com/kepler155c/opus
synced 2025-04-10 09:36:39 +00:00
better startup
This commit is contained in:
parent
f2e1a39584
commit
13efde276d
@ -391,13 +391,21 @@ function Util.loadUrl(url, env) -- loadfile equivalent
|
||||
end
|
||||
|
||||
function Util.runUrl(env, url, ...) -- os.run equivalent
|
||||
setmetatable(env, { __index = _G })
|
||||
local fn, m = Util.loadUrl(url, env)
|
||||
if fn then
|
||||
local args = { ... }
|
||||
fn, m = pcall(function() fn(unpack(args)) end)
|
||||
return pcall(function() return fn(table.unpack(args)) end)
|
||||
end
|
||||
if not fn and m and m ~= '' then
|
||||
-- printError(m)
|
||||
return fn, m
|
||||
end
|
||||
|
||||
function Util.run(env, path, ...)
|
||||
setmetatable(env, { __index = _G })
|
||||
local fn, m = loadfile(path, env)
|
||||
if fn then
|
||||
local args = { ... }
|
||||
return pcall(function() return fn(table.unpack(args)) end)
|
||||
end
|
||||
return fn, m
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ local env = {
|
||||
aliases = shell.aliases(),
|
||||
lua_path = LUA_PATH,
|
||||
}
|
||||
Config.load('multishell', env)
|
||||
Config.load('shell', env)
|
||||
|
||||
UI.TextEntry.defaults.backgroundFocusColor = colors.black
|
||||
|
||||
@ -126,7 +126,7 @@ function systemPage.tabs.pathTab:eventHandler(event)
|
||||
env.path = self.entry.value
|
||||
self.grid:setIndex(self.grid:getIndex())
|
||||
self.grid:draw()
|
||||
Config.update('multishell', env)
|
||||
Config.update('shell', env)
|
||||
systemPage.notification:success('reboot to take effect')
|
||||
return true
|
||||
end
|
||||
@ -148,7 +148,7 @@ function systemPage.tabs.aliasTab:eventHandler(event)
|
||||
env.aliases[self.grid:getSelected().alias] = nil
|
||||
self.grid:setIndex(self.grid:getIndex())
|
||||
self.grid:draw()
|
||||
Config.update('multishell', env)
|
||||
Config.update('shell', env)
|
||||
systemPage.notification:success('reboot to take effect')
|
||||
return true
|
||||
|
||||
@ -158,7 +158,7 @@ function systemPage.tabs.aliasTab:eventHandler(event)
|
||||
self.path:reset()
|
||||
self:draw()
|
||||
self:setFocus(self.alias)
|
||||
Config.update('multishell', env)
|
||||
Config.update('shell', env)
|
||||
systemPage.notification:success('reboot to take effect')
|
||||
return true
|
||||
end
|
||||
|
@ -61,14 +61,12 @@ function shell.run(...)
|
||||
|
||||
local result, err
|
||||
|
||||
local env = Util.shallowCopy(sandboxEnv)
|
||||
if isUrl then
|
||||
local env = Util.shallowCopy(sandboxEnv)
|
||||
setmetatable(env, { __index = _G })
|
||||
result, err = Util.runUrl(env, path, unpack(args))
|
||||
else
|
||||
result, err = os.run(Util.shallowCopy(sandboxEnv), path, unpack(args))
|
||||
result, err = Util.run(env, path, unpack(args))
|
||||
end
|
||||
|
||||
if multishell and multishell.getTitle then
|
||||
local title = 'shell'
|
||||
if #tProgramStack > 0 then
|
||||
@ -237,7 +235,7 @@ if #tArgs > 0 then
|
||||
-- Run the program specified in this new shell
|
||||
local s, m = shell.run( ... )
|
||||
if not s and m and m ~= 'Terminated' then
|
||||
error(m or '')
|
||||
error(m)
|
||||
end
|
||||
return s, m
|
||||
end
|
||||
|
@ -44,16 +44,9 @@ end
|
||||
local function run(file, ...)
|
||||
local s, m = loadfile(file, makeEnv())
|
||||
if s then
|
||||
local args = { ... }
|
||||
s, m = pcall(function()
|
||||
return s(table.unpack(args))
|
||||
end)
|
||||
return s(...)
|
||||
end
|
||||
|
||||
if not s and m then
|
||||
error('Error loading ' .. file .. '\n' .. m)
|
||||
end
|
||||
return m
|
||||
error('Error loading ' .. file .. '\n' .. m)
|
||||
end
|
||||
|
||||
local function runUrl(file, ...)
|
||||
@ -98,7 +91,7 @@ if not fs.exists('usr/config/shell') then
|
||||
Util.writeTable('usr/config/shell', {
|
||||
aliases = shell.aliases(),
|
||||
path = 'usr/apps:sys/apps:' .. shell.path(),
|
||||
LUA_PATH = '/sys/apis:/usr/apis',
|
||||
lua_path = '/sys/apis:/usr/apis',
|
||||
})
|
||||
end
|
||||
|
||||
@ -113,7 +106,7 @@ if config.aliases then
|
||||
end
|
||||
end
|
||||
shell.setPath(config.path)
|
||||
LUA_PATH = config.LUA_PATH
|
||||
LUA_PATH = config.lua_path
|
||||
|
||||
-- extensions
|
||||
local dir = 'sys/extensions'
|
||||
|
2108
sys/etc/recipes.db
2108
sys/etc/recipes.db
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user