diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-10-27 09:26:52 +0100 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-10-27 09:26:52 +0100 |
commit | cb3e2aff5c1665db48bdd274bd696a0d465cbd3a (patch) | |
tree | 937c44e81e836f0c3625e9b5688a8bbfdc91f137 /src | |
parent | 908756d54f22d16b743dad5d5d8314b4fb03817b (diff) | |
download | luarocks-cb3e2aff5c1665db48bdd274bd696a0d465cbd3a.tar.gz luarocks-cb3e2aff5c1665db48bdd274bd696a0d465cbd3a.tar.bz2 luarocks-cb3e2aff5c1665db48bdd274bd696a0d465cbd3a.zip |
explicit warn when enviornment variable given filename doesn't exist
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/cfg.lua | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 70c1bd04..66d3d25a 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -228,17 +228,33 @@ end | |||
228 | if not site_config.LUAROCKS_FORCE_CONFIG then | 228 | if not site_config.LUAROCKS_FORCE_CONFIG then |
229 | 229 | ||
230 | home_config_file_default = home_config_dir.."/config-"..cfg.lua_version..".lua" | 230 | home_config_file_default = home_config_dir.."/config-"..cfg.lua_version..".lua" |
231 | local list = { | ||
232 | os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG"), | ||
233 | home_config_file_default, | ||
234 | home_config_dir.."/config.lua", | ||
235 | } | ||
236 | -- first entry might be a silent nil, check and remove if so | ||
237 | if not list[1] then table.remove(list, 1) end | ||
238 | 231 | ||
239 | home_config_file = load_config_file(list) | 232 | local config_env_var = "LUAROCKS_CONFIG_" .. version_suffix |
240 | home_config_ok = (home_config_file ~= nil) | 233 | local config_env_value = os.getenv(config_env_var) |
234 | if not config_env_value then | ||
235 | config_env_var = "LUAROCKS_CONFIG" | ||
236 | config_env_value = os.getenv(config_env_var) | ||
237 | end | ||
238 | |||
239 | -- first try environment provided file, so we can explicitly warn when it is missing | ||
240 | if config_env_value then | ||
241 | local list = { config_env_value } | ||
242 | home_config_file = load_config_file(list) | ||
243 | home_config_ok = (home_config_file ~= nil) | ||
244 | if not home_config_ok then | ||
245 | io.stderr:write("Warning: could not load configuration file `"..config_env_value.."` given in environment variable "..config_env_var.."\n") | ||
246 | end | ||
247 | end | ||
241 | 248 | ||
249 | -- try the alternative defaults if there was no environment specified file or it didn't work | ||
250 | if not home_config_ok then | ||
251 | local list = { | ||
252 | home_config_file_default, | ||
253 | home_config_dir.."/config.lua", | ||
254 | } | ||
255 | home_config_file = load_config_file(list) | ||
256 | home_config_ok = (home_config_file ~= nil) | ||
257 | end | ||
242 | end | 258 | end |
243 | 259 | ||
244 | 260 | ||