lualoader: Intercept boot cli command
This should be functional and roughly equivalent to the Forth version. Stop doing a loadelf() on menu exit now that we can DTRT with boot invocations. autoboot interception will follow not long after.
This commit is contained in:
parent
683ca3a432
commit
f0cb3b6b25
@ -37,6 +37,38 @@ local compose_loader_cmd = function(cmd_name, argstr)
|
||||
return cmd_name;
|
||||
end
|
||||
|
||||
-- Parses arguments to boot and returns two values: kernel_name, argstr
|
||||
-- Defaults to nil and "" respectively.
|
||||
local parse_boot_args = function(argv)
|
||||
if (#argv == 0) then
|
||||
return nil, "";
|
||||
end
|
||||
local kernel_name;
|
||||
local argstr = "";
|
||||
|
||||
for k, v in ipairs(argv) do
|
||||
if (v:sub(1,1) ~= "-") then
|
||||
kernel_name = v;
|
||||
else
|
||||
argstr = argstr .. " " .. v;
|
||||
end
|
||||
end
|
||||
return kernel_name, argstr;
|
||||
end
|
||||
|
||||
-- Globals
|
||||
function boot(...)
|
||||
local argv = {...};
|
||||
local cmd_name = "";
|
||||
cmd_name, argv = core.popFrontTable(argv);
|
||||
local kernel, argstr = parse_boot_args(argv);
|
||||
if (kernel ~= nil) then
|
||||
loader.perform("unload");
|
||||
config.selectkernel(kernel);
|
||||
end
|
||||
core.boot(argstr);
|
||||
end
|
||||
|
||||
-- Module exports
|
||||
-- Commonly appearing constants
|
||||
core.KEY_BACKSPACE = 8;
|
||||
|
@ -390,7 +390,6 @@ function menu.run(m)
|
||||
if (m == menu.welcome) then
|
||||
screen.defcursor();
|
||||
print("Exiting menu!");
|
||||
config.loadelf();
|
||||
return false;
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user