Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F162299077
D14658.id40755.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D14658.id40755.diff
View Options
Index: head/stand/lua/core.lua
===================================================================
--- head/stand/lua/core.lua
+++ head/stand/lua/core.lua
@@ -41,6 +41,26 @@
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
Index: head/stand/lua/loader.lua
===================================================================
--- head/stand/lua/loader.lua
+++ head/stand/lua/loader.lua
@@ -43,11 +43,7 @@
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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jul 12, 8:06 PM (10 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35010062
Default Alt Text
D14658.id40755.diff (1 KB)
Attached To
Mode
D14658: liblua: Implement try_include and use it for inclusion of the local module
Attached
Detach File
Event Timeline
Log In to Comment