aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2015-06-16 19:31:01 +0200
committerThijs Schreijer <thijs@thijsschreijer.nl>2015-06-16 19:31:01 +0200
commite1dd6375822d800984e1d3d821899a315bc1b222 (patch)
tree247b0977c84a108469d675b04bd9eab4229375df
parentbaf7ffa63ab48b73bd328f9a9153a7f2cfecbc25 (diff)
downloadluarocks-e1dd6375822d800984e1d3d821899a315bc1b222.tar.gz
luarocks-e1dd6375822d800984e1d3d821899a315bc1b222.tar.bz2
luarocks-e1dd6375822d800984e1d3d821899a315bc1b222.zip
added 2 functions to the global environment of the config-file loader sandbox; `os_getenv()` and `__dump_env()`
-rw-r--r--src/luarocks/cfg.lua17
1 files changed, 16 insertions, 1 deletions
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
145cfg.variables = {} 145cfg.variables = {}
146cfg.rocks_trees = {} 146cfg.rocks_trees = {}
147 147
148-- some extras for the global enviornment in the config files;
149cfg.os_getenv = os.getenv
150cfg.__dump_env = function()
151 -- debug function, calling it from a config file will show all
152 -- available globals to that config file
153 print(util.show_table(cfg, "global environment"))
154end
155
148sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" 156sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua"
149do 157do
150 local err, errcode 158 local err, errcode
@@ -159,11 +167,18 @@ do
159 end 167 end
160end 168end
161 169
162local env_for_config_file = { 170local env_for_config_file
171env_for_config_file = {
163 home = cfg.home, 172 home = cfg.home,
164 lua_version = cfg.lua_version, 173 lua_version = cfg.lua_version,
165 platform = util.make_shallow_copy(detected), 174 platform = util.make_shallow_copy(detected),
166 processor = proc, 175 processor = proc,
176 os_getenv = os.getenv,
177 __dump_env = function()
178 -- debug function, calling it from a config file will show all
179 -- available globals to that config file
180 print(util.show_table(env_for_config_file, "global environment"))
181 end,
167} 182}
168 183
169if not site_config.LUAROCKS_FORCE_CONFIG then 184if not site_config.LUAROCKS_FORCE_CONFIG then