diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-06-16 19:31:01 +0200 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-06-16 19:31:01 +0200 |
commit | e1dd6375822d800984e1d3d821899a315bc1b222 (patch) | |
tree | 247b0977c84a108469d675b04bd9eab4229375df | |
parent | baf7ffa63ab48b73bd328f9a9153a7f2cfecbc25 (diff) | |
download | luarocks-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.lua | 17 |
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 | |||
145 | cfg.variables = {} | 145 | cfg.variables = {} |
146 | cfg.rocks_trees = {} | 146 | cfg.rocks_trees = {} |
147 | 147 | ||
148 | -- some extras for the global enviornment in the config files; | ||
149 | cfg.os_getenv = os.getenv | ||
150 | cfg.__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")) | ||
154 | end | ||
155 | |||
148 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" | 156 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" |
149 | do | 157 | do |
150 | local err, errcode | 158 | local err, errcode |
@@ -159,11 +167,18 @@ do | |||
159 | end | 167 | end |
160 | end | 168 | end |
161 | 169 | ||
162 | local env_for_config_file = { | 170 | local env_for_config_file |
171 | env_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 | ||
169 | if not site_config.LUAROCKS_FORCE_CONFIG then | 184 | if not site_config.LUAROCKS_FORCE_CONFIG then |