diff options
author | Ferenc Wágner <wferi@niif.hu> | 2014-10-13 12:42:16 +0200 |
---|---|---|
committer | Ferenc Wágner <wferi@niif.hu> | 2014-10-13 12:44:15 +0200 |
commit | 68cb978ab7e692d772e4d62d3585b8f7bac43b4b (patch) | |
tree | 6b8bf5e43f112ce81342940347c07e4439996559 | |
parent | 6b68a381be780b83a1df0033fd82819a6d642676 (diff) | |
download | syslinux-68cb978ab7e692d772e4d62d3585b8f7bac43b4b.tar.gz |
lua: simplify the function/value handling in the automenu test
Signed-off-by: Ferenc Wágner <wferi@niif.hu>
-rw-r--r-- | com32/lua/test/automenu.lua | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/com32/lua/test/automenu.lua b/com32/lua/test/automenu.lua index 891adbc0..002fb095 100644 --- a/com32/lua/test/automenu.lua +++ b/com32/lua/test/automenu.lua @@ -50,7 +50,7 @@ local function scan (params) initrd = nil end table.insert (params.items, { - show = function () return name .. (initrd and " +initrd" or "") end, + show = name .. (initrd and " +initrd" or ""), version = version, execute = function () boot (path, initrd, @@ -94,21 +94,18 @@ local function kernel_gt (k1, k2) return version_gt (k1.version, k2.version) end -local function print_or_call (x, def) - local t = type (x) - if t == "nil" then - if def then print (def) end - elseif t == "function" then - x () +local function get (x) + if type (x) == "function" then + return x () else - print (x) + return x end end local function draw (params) - print_or_call (params.title, "\n=== Boot menu ===") + print (get (params.title) or "\n=== Boot menu ===") for i, item in ipairs (params.items) do - print ((i == params.default and " > " or " ") .. i .. " " .. item.show ()) + print ((i == params.default and " > " or " ") .. i .. " " .. get (item.show)) end print ("\nKernel arguments:\n " .. params.append .. modifiers ()) print ("\nHit a number to select from the menu,\n ENTER to accept default,\n ESC to exit\n or any other key to print menu again") |