From e1dd6375822d800984e1d3d821899a315bc1b222 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 16 Jun 2015 19:31:01 +0200 Subject: added 2 functions to the global environment of the config-file loader sandbox; `os_getenv()` and `__dump_env()` --- src/luarocks/cfg.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 20aa4a21..6d6a911d 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -145,6 +145,14 @@ end cfg.variables = {} cfg.rocks_trees = {} +-- some extras for the global enviornment in the config files; +cfg.os_getenv = os.getenv +cfg.__dump_env = function() + -- debug function, calling it from a config file will show all + -- available globals to that config file + print(util.show_table(cfg, "global environment")) +end + sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" do local err, errcode @@ -159,11 +167,18 @@ do end end -local env_for_config_file = { +local env_for_config_file +env_for_config_file = { home = cfg.home, lua_version = cfg.lua_version, platform = util.make_shallow_copy(detected), processor = proc, + os_getenv = os.getenv, + __dump_env = function() + -- debug function, calling it from a config file will show all + -- available globals to that config file + print(util.show_table(env_for_config_file, "global environment")) + end, } if not site_config.LUAROCKS_FORCE_CONFIG then -- cgit v1.2.3-55-g6feb