From 3aa7e7a08f0dd756e31ce34e4c9ae9bf0169d49a Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 20 Mar 2014 13:54:07 -0300 Subject: Bring the Unix implementation up to par with the Windows one! --- src/luarocks/fs/unix/tools.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index df2eee3f..1f4f2a4e 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua @@ -18,9 +18,13 @@ end -- Uses the module's internal directory stack. -- @return string: the absolute pathname of the current directory. function current_dir() - local pipe = io.popen(vars.PWD) - local current = pipe:read("*l") - pipe:close() + local current = cfg.cache_pwd + if not current then + local pipe = io.popen(fs.Q(vars.PWD)) + current = pipe:read("*l") + pipe:close() + cfg.cache_pwd = current + end for _, directory in ipairs(dir_stack) do current = fs.absolute_name(directory, current) end @@ -33,7 +37,7 @@ end -- @return boolean: true if command succeeds (status code 0), false -- otherwise. function execute_string(cmd) - local code = os.execute(command_at(fs.current_dir(), cmd)) + local code, err = os.execute(command_at(fs.current_dir(), cmd)) if code == 0 or code == true then return true else -- cgit v1.2.3-55-g6feb