diff options
-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 |