From 780d5e7828fef17b79a421ce4a6e131514e6a288 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 12 Dec 2023 18:31:43 -0300 Subject: fs.tools: do not cd to initial directory Fixes #1545 --- src/luarocks/fs/tools.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/luarocks/fs/tools.lua b/src/luarocks/fs/tools.lua index 5c317f65..ff29ea39 100644 --- a/src/luarocks/fs/tools.lua +++ b/src/luarocks/fs/tools.lua @@ -64,7 +64,7 @@ do for _, directory in ipairs(dir_stack) do current = fs.absolute_name(directory, current) end - return current + return current, cache_pwd end end @@ -107,9 +107,11 @@ end -- @return boolean: true if command succeeds (status code 0), false -- otherwise. function tools.execute_string(cmd) - local current = fs.current_dir() + local current, cache_pwd = fs.current_dir() if not current then return false end - cmd = fs.command_at(current, cmd) + if current ~= cache_pwd then + cmd = fs.command_at(current, cmd) + end local code = os.execute(cmd) if code == 0 or code == true then return true -- cgit v1.2.3-55-g6feb