diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-26 17:47:28 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-27 13:28:33 -0300 |
| commit | 5cba4b83f60966045b86ac615df2692c953ebba7 (patch) | |
| tree | 445d1f58e589b53e4ee8cda5984f430f54fd2b36 /src | |
| parent | 6bc6ede826843c3692971c14c27c3d27714b2126 (diff) | |
| download | luarocks-5cba4b83f60966045b86ac615df2692c953ebba7.tar.gz luarocks-5cba4b83f60966045b86ac615df2692c953ebba7.tar.bz2 luarocks-5cba4b83f60966045b86ac615df2692c953ebba7.zip | |
fix(fs): make current_dir always return 1 arg only
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fs/tools.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/luarocks/fs/tools.lua b/src/luarocks/fs/tools.lua index a7724dc7..23f2561e 100644 --- a/src/luarocks/fs/tools.lua +++ b/src/luarocks/fs/tools.lua | |||
| @@ -48,12 +48,11 @@ do | |||
| 48 | end | 48 | end |
| 49 | end | 49 | end |
| 50 | 50 | ||
| 51 | local current_dir_with_cache | ||
| 51 | do | 52 | do |
| 52 | local cache_pwd | 53 | local cache_pwd |
| 53 | --- Obtain current directory. | 54 | |
| 54 | -- Uses the module's internal directory stack. | 55 | current_dir_with_cache = function() |
| 55 | -- @return string: the absolute pathname of the current directory. | ||
| 56 | function tools.current_dir() | ||
| 57 | local current = cache_pwd | 56 | local current = cache_pwd |
| 58 | if not current then | 57 | if not current then |
| 59 | local pipe = io.popen(fs.quiet_stderr(vars.PWD)) | 58 | local pipe = io.popen(fs.quiet_stderr(vars.PWD)) |
| @@ -66,6 +65,13 @@ do | |||
| 66 | end | 65 | end |
| 67 | return current, cache_pwd | 66 | return current, cache_pwd |
| 68 | end | 67 | end |
| 68 | |||
| 69 | --- Obtain current directory. | ||
| 70 | -- Uses the module's internal directory stack. | ||
| 71 | -- @return string: the absolute pathname of the current directory. | ||
| 72 | function tools.current_dir() | ||
| 73 | return (current_dir_with_cache()) -- drop second return | ||
| 74 | end | ||
| 69 | end | 75 | end |
| 70 | 76 | ||
| 71 | --- Change the current directory. | 77 | --- Change the current directory. |
| @@ -107,7 +113,7 @@ end | |||
| 107 | -- @return boolean: true if command succeeds (status code 0), false | 113 | -- @return boolean: true if command succeeds (status code 0), false |
| 108 | -- otherwise. | 114 | -- otherwise. |
| 109 | function tools.execute_string(cmd) | 115 | function tools.execute_string(cmd) |
| 110 | local current, cache_pwd = fs.current_dir() | 116 | local current, cache_pwd = current_dir_with_cache() |
| 111 | if not current then return false end | 117 | if not current then return false end |
| 112 | if current ~= cache_pwd then | 118 | if current ~= cache_pwd then |
| 113 | cmd = fs.command_at(current, cmd) | 119 | cmd = fs.command_at(current, cmd) |
