core.lua (ab97d42addae97a389c6f22d6bba62ed954bb8e7) core.lua (522a65a8d97a0d6b634266f1b4a89aa8f374279c)
1--
2-- SPDX-License-Identifier: BSD-2-Clause
3--
4-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
5-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
6-- All rights reserved.
7--
8-- Redistribution and use in source and binary forms, with or without

--- 51 unchanged lines hidden (view full) ---

60end
61
62
63-- Globals
64-- try_include will return the loaded module on success, or false and the error
65-- message on failure.
66function try_include(module)
67 if module:sub(1, 1) ~= "/" then
1--
2-- SPDX-License-Identifier: BSD-2-Clause
3--
4-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
5-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
6-- All rights reserved.
7--
8-- Redistribution and use in source and binary forms, with or without

--- 51 unchanged lines hidden (view full) ---

60end
61
62
63-- Globals
64-- try_include will return the loaded module on success, or false and the error
65-- message on failure.
66function try_include(module)
67 if module:sub(1, 1) ~= "/" then
68 module = loader.lua_path .. "/" .. module
68 local lua_path = loader.lua_path
69 -- XXX Temporary compat shim; this should be removed once the
70 -- loader.lua_path export has sufficiently spread.
71 if lua_path == nil then
72 lua_path = "/boot/lua"
73 end
74 module = lua_path .. "/" .. module
69 -- We only attempt to append an extension if an absolute path
70 -- wasn't specified. This assumes that the caller either wants
71 -- to treat this like it would require() and specify just the
72 -- base filename, or they know what they're doing as they've
73 -- specified an absolute path and we shouldn't impede.
74 if module:match(".lua$") == nil then
75 module = module .. ".lua"
76 end

--- 465 unchanged lines hidden ---
75 -- We only attempt to append an extension if an absolute path
76 -- wasn't specified. This assumes that the caller either wants
77 -- to treat this like it would require() and specify just the
78 -- base filename, or they know what they're doing as they've
79 -- specified an absolute path and we shouldn't impede.
80 if module:match(".lua$") == nil then
81 module = module .. ".lua"
82 end

--- 465 unchanged lines hidden ---