diff options
| author | Kyle Evans <kevans@FreeBSD.org> | 2018-03-26 19:01:22 +0000 |
|---|---|---|
| committer | Kyle Evans <kevans@FreeBSD.org> | 2018-03-26 19:01:22 +0000 |
| commit | 07faaf781556369bf1239dd727a3e0396b4d88a7 (patch) | |
| tree | 99cf11ca21641cd6f62d05c7b5aa1300542bfa64 /stand/lua | |
| parent | 60fde7ce5d7bf5d94290720ea53db5701ab406a8 (diff) | |
Notes
Diffstat (limited to 'stand/lua')
| -rw-r--r-- | stand/lua/core.lua | 20 | ||||
| -rw-r--r-- | stand/lua/loader.lua | 6 |
2 files changed, 21 insertions, 5 deletions
diff --git a/stand/lua/core.lua b/stand/lua/core.lua index b3d5308bf1cd..6980d798c296 100644 --- a/stand/lua/core.lua +++ b/stand/lua/core.lua @@ -41,6 +41,26 @@ local function composeLoaderCmd(cmd_name, argstr) return cmd_name end +-- Globals +-- try_include will return the loaded module on success, or nil on failure. +-- A message will also be printed on failure, with one exception: non-verbose +-- loading will suppress 'module not found' errors. +function try_include(module) + local status, ret = pcall(require, module) + -- ret is the module if we succeeded. + if status then + return ret + end + -- Otherwise, ret is just a message; filter out ENOENT unless we're + -- doing a verbose load. As a consequence, try_include prior to loading + -- configuration will not display 'module not found'. All other errors + -- in loading will be printed. + if config.verbose or ret:match("^module .+ not found") == nil then + print(ret) + end + return nil +end + -- Module exports -- Commonly appearing constants core.KEY_BACKSPACE = 8 diff --git a/stand/lua/loader.lua b/stand/lua/loader.lua index 2486193af031..81034aa9a671 100644 --- a/stand/lua/loader.lua +++ b/stand/lua/loader.lua @@ -43,11 +43,7 @@ if not core.isMenuSkipped() then end local password = require("password") -local result = lfs.attributes("/boot/lua/local.lua") --- Effectively discard any errors; we'll just act if it succeeds. -if result ~= nil then - require("local") -end +try_include("local") config.load() if core.isUEFIBoot() then |
