diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2019-05-07 16:51:00 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2019-05-07 16:51:00 -0300 |
commit | 923f37301736155e1db07e540bc0e57e211d5380 (patch) | |
tree | e6efa32d895558e47c9101d325961d122c787d27 | |
parent | 9cb923d86dec6af01d4b4fc93ad1b03b1d18c794 (diff) | |
download | luarocks-923f37301736155e1db07e540bc0e57e211d5380.tar.gz luarocks-923f37301736155e1db07e540bc0e57e211d5380.tar.bz2 luarocks-923f37301736155e1db07e540bc0e57e211d5380.zip |
cmd: fix handling of unconfigured paths in get_lua_version
-rw-r--r-- | src/luarocks/cmd.lua | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 284b1602..cb669226 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -157,18 +157,15 @@ local function get_lua_version(flags) | |||
157 | return flags["lua-version"] | 157 | return flags["lua-version"] |
158 | end | 158 | end |
159 | local dirs = {} | 159 | local dirs = {} |
160 | local next_i = 1 | ||
161 | if flags["project-tree"] then | 160 | if flags["project-tree"] then |
162 | dirs[next_i] = dir.path(flags["project-tree"], "..", ".luarocks") | 161 | table.insert(dirs, dir.path(flags["project-tree"], "..", ".luarocks")) |
163 | next_i = next_i + 1 | ||
164 | end | 162 | end |
165 | if cfg.home_tree then | 163 | if cfg.home_tree then |
166 | dirs[next_i] = dir.path(cfg.home_tree, ".luarocks") | 164 | table.insert(dirs, dir.path(cfg.home_tree, ".luarocks")) |
167 | next_i = next_i + 1 | ||
168 | end | 165 | end |
169 | dirs[next_i] = cfg.sysconfdir | 166 | table.insert(dirs, cfg.sysconfdir) |
170 | for i=1, next_i do | 167 | for _, d in ipairs(dirs) do |
171 | local f = dir.path(dirs[i], "default-lua-version.lua") | 168 | local f = dir.path(d, "default-lua-version.lua") |
172 | local mod, err = loadfile(f, "t") | 169 | local mod, err = loadfile(f, "t") |
173 | if mod then | 170 | if mod then |
174 | local pok, ver = pcall(mod) | 171 | local pok, ver = pcall(mod) |