# HG changeset patch # User jbe # Date 1425161083 -3600 # Node ID 2eda136b0394bfceb90389a02e1be37b74c1de53 # Parent d3273921ce75bd69585585b9c7fb31da7b39242d Replace global environment as soon as possible in mcp.lua diff -r d3273921ce75 -r 2eda136b0394 framework/bin/mcp.lua --- a/framework/bin/mcp.lua Fri Feb 27 22:56:58 2015 +0100 +++ b/framework/bin/mcp.lua Sat Feb 28 23:04:43 2015 +0100 @@ -2,6 +2,16 @@ WEBMCP_VERSION = "2.0.0_devel" +-- allow control of global environment +local _G = _G +local global_metatable = { + __index = _G, + __newindex = function(self, key, value) + _G[key] = value + end +} +_ENV = setmetatable({}, global_metatable) + -- check if interactive mode if listen then -- defined by moonbridge WEBMCP_MODE = "listen" @@ -172,12 +182,9 @@ end -- prohibit (unintended) definition of new global variables -_ENV = setmetatable({}, { - __index = _G, - __newindex = function() - error("Setting of global variable prohibited") - end -}) +function global_metatable.__newindex() + error("Setting of global variable prohibited") +end -- execute configurations and pre-fork initializers for i, config_name in ipairs(WEBMCP_CONFIG_NAMES) do