From 4ab6969557d25d2d7d422d2829f9d604f21fbae8 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 28 May 2014 15:30:23 -0300 Subject: Dehardcode the separator for PATH variables, fixing behavior on Unix. --- src/luarocks/cfg.lua | 2 +- src/luarocks/path_cmd.lua | 9 +++++---- src/luarocks/util.lua | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index a96d610f..05d58a10 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -544,7 +544,7 @@ function cfg.package_paths() if extra_luarocks_module_dir then table.insert(new_path, extra_luarocks_module_dir) end - return table.concat(new_path, ";"), table.concat(new_cpath, ";"), table.concat(new_bin, ";") + return table.concat(new_path, ";"), table.concat(new_cpath, ";"), table.concat(new_bin, cfg.export_path_separator) end function cfg.which_config() diff --git a/src/luarocks/path_cmd.lua b/src/luarocks/path_cmd.lua index 4aeba41c..95532f9f 100644 --- a/src/luarocks/path_cmd.lua +++ b/src/luarocks/path_cmd.lua @@ -39,6 +39,7 @@ function path_cmd.run(...) local deps_mode = deps.get_deps_mode(flags) local lr_path, lr_cpath, lr_bin = cfg.package_paths() + local path_sep = cfg.export_path_separator if flags["lr-path"] then util.printout(util.remove_path_dupes(lr_path, ';')) @@ -47,24 +48,24 @@ function path_cmd.run(...) util.printout(util.remove_path_dupes(lr_cpath, ';')) return true elseif flags["lr-bin"] then - util.printout(util.remove_path_dupes(lr_bin, ';')) + util.printout(util.remove_path_dupes(lr_bin, path_sep)) return true end if flags["append"] then lr_path = package.path .. ";" .. lr_path lr_cpath = package.cpath .. ";" .. lr_cpath - lr_bin = os.getenv("PATH") .. ";" .. lr_bin + lr_bin = os.getenv("PATH") .. path_sep .. lr_bin else lr_path = lr_path.. ";" .. package.path lr_cpath = lr_cpath .. ";" .. package.cpath - lr_bin = lr_bin .. ";" .. os.getenv("PATH") + lr_bin = lr_bin .. path_sep .. os.getenv("PATH") end util.printout(cfg.export_lua_path:format(util.remove_path_dupes(lr_path, ';'))) util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(lr_cpath, ';'))) if flags["bin"] then - util.printout(cfg.export_path:format(util.remove_path_dupes(lr_bin,';'))) + util.printout(cfg.export_path:format(util.remove_path_dupes(lr_bin, path_sep))) end return true end diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index a70e726d..1bf6533b 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -432,6 +432,7 @@ function util.remove_path_dupes(list, sep) local parts = util.split_string(list, sep) local final, entries = {}, {} for _, part in ipairs(parts) do + part = part:gsub("//", "/") if not entries[part] then table.insert(final, part) entries[part] = true -- cgit v1.2.3-55-g6feb