From 66c852785b3dc9bc05480619e25b510b0fd4c2f4 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 9 Aug 2011 01:15:34 -0300 Subject: current_dir() should not assume that the PWD environment variable is valid (closes #31) --- src/luarocks/fs/unix/tools.lua | 9 +++------ src/luarocks/fs/win32/tools.lua | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index f63efc41..9cd4ca1c 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua @@ -26,12 +26,9 @@ end -- Uses the module's internal dir stack. -- @return string: the absolute pathname of the current directory. function current_dir() - local current = os.getenv("PWD") - if not current then - local pipe = io.popen("pwd") - current = pipe:read("*l") - pipe:close() - end + local pipe = io.popen("pwd") + local current = pipe:read("*l") + pipe:close() for _, d in ipairs(dir_stack) do current = fs.absolute_name(d, current) end diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index dcbd5701..a3b7cdd0 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua @@ -43,12 +43,9 @@ end -- Uses the module's internal dir stack. -- @return string: the absolute pathname of the current directory. function current_dir() - local current = os.getenv("PWD") - if not current then - local pipe = io.popen("pwd") - current = pipe:read("*l") - pipe:close() - end + local pipe = io.popen("pwd") + local current = pipe:read("*l") + pipe:close() for _, d in ipairs(dir_stack) do current = fs.absolute_name(d, current) end -- cgit v1.2.3-55-g6feb