From de978bfcc0b90600ab3a0e0d22e4fd7dd5a6d387 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad <hisham@gobolinux.org> Date: Mon, 11 Apr 2022 17:33:05 -0300 Subject: fs.is_tool_available: if it looks like a pathname, try that first Some uses of is_tool_available use binary names that can be overriden by the user via configuration. --- src/luarocks/fs/lua.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 2619d136..96017daa 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -123,7 +123,20 @@ function fs_lua.is_tool_available(tool_cmd, tool_name) ok = tool_available_cache[tool_name] else local tool_cmd_no_args = tool_cmd:gsub(" .*", "") - ok = fs.search_in_path(tool_cmd_no_args) + + -- if it looks like the tool has a pathname, try that first + if tool_cmd_no_args:match("[/\\]") then + local fd = io.open(tool_cmd_no_args, "r") + if fd then + fd:close() + ok = true + end + end + + if not ok then + ok = fs.search_in_path(tool_cmd_no_args) + end + tool_available_cache[tool_name] = (ok == true) end -- cgit v1.2.3-55-g6feb