configmanager: Make _G accessible via `Lua` variable, deprecate direct access
authorMatthew Wild <mwild1@gmail.com>
Fri, 08 Dec 2023 14:24:49 +0000
changeset 13393 47d0d80da208
parent 13392 de6c1a170871
child 13394 905a6009f60d
configmanager: Make _G accessible via `Lua` variable, deprecate direct access
core/configmanager.lua
--- a/core/configmanager.lua	Fri Dec 08 13:36:51 2023 +0000
+++ b/core/configmanager.lua	Fri Dec 08 14:24:49 2023 +0000
@@ -129,11 +129,22 @@
 					if k:match("^ENV_") then
 						return os.getenv(k:sub(5));
 					end
+					if k == "Lua" then
+						return _G;
+					end
 					local val = rawget_option(config_table, env.__currenthost or "*", k);
+
 					if val ~= nil then
 						return val;
 					end
-					return rawget(_G, k);
+
+					local g_val = rawget(_G, k);
+
+					if g_val ~= nil then
+						t_insert(warnings, ("%s:%d: direct usage of the Lua API is deprecated - replace `%s` with `Lua.%s`"):format(config_file, get_line_number(config_file), k, k));
+					end
+
+					return g_val;
 				end,
 				__newindex = function (_, k, v)
 					local host = env.__currenthost or "*";