diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2011-08-09 01:15:34 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-08-09 01:15:34 -0300 |
| commit | 66c852785b3dc9bc05480619e25b510b0fd4c2f4 (patch) | |
| tree | 95b953a94b97e79193822feab5095688bbac4beb /src | |
| parent | 25de237619d97b5c9ff04a846b20738d11162596 (diff) | |
| download | luarocks-66c852785b3dc9bc05480619e25b510b0fd4c2f4.tar.gz luarocks-66c852785b3dc9bc05480619e25b510b0fd4c2f4.tar.bz2 luarocks-66c852785b3dc9bc05480619e25b510b0fd4c2f4.zip | |
current_dir() should not assume that the PWD environment variable is valid (closes #31)
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fs/unix/tools.lua | 9 | ||||
| -rw-r--r-- | src/luarocks/fs/win32/tools.lua | 9 |
2 files changed, 6 insertions, 12 deletions
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 | |||
| 26 | -- Uses the module's internal dir stack. | 26 | -- Uses the module's internal dir stack. |
| 27 | -- @return string: the absolute pathname of the current directory. | 27 | -- @return string: the absolute pathname of the current directory. |
| 28 | function current_dir() | 28 | function current_dir() |
| 29 | local current = os.getenv("PWD") | 29 | local pipe = io.popen("pwd") |
| 30 | if not current then | 30 | local current = pipe:read("*l") |
| 31 | local pipe = io.popen("pwd") | 31 | pipe:close() |
| 32 | current = pipe:read("*l") | ||
| 33 | pipe:close() | ||
| 34 | end | ||
| 35 | for _, d in ipairs(dir_stack) do | 32 | for _, d in ipairs(dir_stack) do |
| 36 | current = fs.absolute_name(d, current) | 33 | current = fs.absolute_name(d, current) |
| 37 | end | 34 | 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 | |||
| 43 | -- Uses the module's internal dir stack. | 43 | -- Uses the module's internal dir stack. |
| 44 | -- @return string: the absolute pathname of the current directory. | 44 | -- @return string: the absolute pathname of the current directory. |
| 45 | function current_dir() | 45 | function current_dir() |
| 46 | local current = os.getenv("PWD") | 46 | local pipe = io.popen("pwd") |
| 47 | if not current then | 47 | local current = pipe:read("*l") |
| 48 | local pipe = io.popen("pwd") | 48 | pipe:close() |
| 49 | current = pipe:read("*l") | ||
| 50 | pipe:close() | ||
| 51 | end | ||
| 52 | for _, d in ipairs(dir_stack) do | 49 | for _, d in ipairs(dir_stack) do |
| 53 | current = fs.absolute_name(d, current) | 50 | current = fs.absolute_name(d, current) |
| 54 | end | 51 | end |
