From 3855e599dd9f7da7d1f1956d7523279146f9bd76 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 14 Mar 2019 17:11:22 -0300 Subject: core.cfg: make detection of sysconfdir version independent When LuaRocks is running on Lua 5.3 and a user uses --lua-version=5.1, this allows sysconfdir to continue being detected correctly. --- src/luarocks/core/cfg.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 399912d5..9859c6b3 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua @@ -47,7 +47,7 @@ local platform_order = { "mingw32", } -local function detect_sysconfdir(lua_version) +local function detect_sysconfdir() local src = debug.getinfo(1, "S").source:gsub("\\", "/"):gsub("/+", "/") if src:sub(1, 1) == "@" then src = src:sub(2) @@ -57,7 +57,7 @@ local function detect_sysconfdir(lua_version) return end -- If installed in a Unix-like tree, use a Unix-like sysconfdir - local installdir = basedir:match("^(.*)/share/lua/" .. lua_version .. "$") + local installdir = basedir:match("^(.*)/share/lua/[^/]*$") if installdir then if installdir == "/usr" then return "/etc/luarocks" @@ -77,7 +77,7 @@ local function set_confdirs(cfg, platforms, hardcoded_sysconfdir) cfg.sysconfdir = sysconfdir or ((os.getenv("PROGRAMFILES") or "c:") .. "/luarocks") else if not sysconfdir then - sysconfdir = detect_sysconfdir(cfg.lua_version) + sysconfdir = detect_sysconfdir() end cfg.home = os.getenv("HOME") or "" cfg.home_tree = (os.getenv("USER") ~= "root") and cfg.home.."/.luarocks" -- cgit v1.2.3-55-g6feb