diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-18 19:58:44 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-19 00:00:49 -0300 |
| commit | f67bf0e2bb0c8d136774ef138dbd8cce365bf9b3 (patch) | |
| tree | c816113fa5eb6f113069dd22ffb6d6a8888379e9 /src | |
| parent | 0ebba5ec21ed524235d95b37e0c5dfff4fd36e81 (diff) | |
| download | luarocks-f67bf0e2bb0c8d136774ef138dbd8cce365bf9b3.tar.gz luarocks-f67bf0e2bb0c8d136774ef138dbd8cce365bf9b3.tar.bz2 luarocks-f67bf0e2bb0c8d136774ef138dbd8cce365bf9b3.zip | |
fix program search when using absolute paths and .exe extensions
Fixes #1001.
Thanks @badrazizi for the suggestion!
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fs/unix.lua | 10 | ||||
| -rw-r--r-- | src/luarocks/fs/win32.lua | 16 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index f3db5b30..6bc183cb 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
| @@ -227,6 +227,16 @@ function unix.system_cache_dir() | |||
| 227 | end | 227 | end |
| 228 | 228 | ||
| 229 | function unix.search_in_path(program) | 229 | function unix.search_in_path(program) |
| 230 | if program:match("/") then | ||
| 231 | local fd = io.open(dir.path(program), "r") | ||
| 232 | if fd then | ||
| 233 | fd:close() | ||
| 234 | return true, program | ||
| 235 | end | ||
| 236 | |||
| 237 | return false | ||
| 238 | end | ||
| 239 | |||
| 230 | for d in (os.getenv("PATH") or ""):gmatch("([^:]+)") do | 240 | for d in (os.getenv("PATH") or ""):gmatch("([^:]+)") do |
| 231 | local fd = io.open(dir.path(d, program), "r") | 241 | local fd = io.open(dir.path(d, program), "r") |
| 232 | if fd then | 242 | if fd then |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 1842ac4c..879f3e76 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
| @@ -374,8 +374,22 @@ function win32.system_cache_dir() | |||
| 374 | end | 374 | end |
| 375 | 375 | ||
| 376 | function win32.search_in_path(program) | 376 | function win32.search_in_path(program) |
| 377 | if program:match("\\") then | ||
| 378 | local fd = io.open(dir.path(program), "r") | ||
| 379 | if fd then | ||
| 380 | fd:close() | ||
| 381 | return true, program | ||
| 382 | end | ||
| 383 | |||
| 384 | return false | ||
| 385 | end | ||
| 386 | |||
| 387 | if not program:lower():match("exe$") then | ||
| 388 | program = program .. ".exe" | ||
| 389 | end | ||
| 390 | |||
| 377 | for d in (os.getenv("PATH") or ""):gmatch("([^;]+)") do | 391 | for d in (os.getenv("PATH") or ""):gmatch("([^;]+)") do |
| 378 | local fd = io.open(dir.path(d, program .. ".exe"), "r") | 392 | local fd = io.open(dir.path(d, program), "r") |
| 379 | if fd then | 393 | if fd then |
| 380 | fd:close() | 394 | fd:close() |
| 381 | return true, d | 395 | return true, d |
