diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2022-04-11 17:33:05 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2022-04-11 17:34:16 -0300 |
commit | de978bfcc0b90600ab3a0e0d22e4fd7dd5a6d387 (patch) | |
tree | 712b9bacf4fe1040c17ad514392a0b668341244a | |
parent | f1a09fe49db5ee123c3edd34aa88e8bb03231ede (diff) | |
download | luarocks-de978bfcc0b90600ab3a0e0d22e4fd7dd5a6d387.tar.gz luarocks-de978bfcc0b90600ab3a0e0d22e4fd7dd5a6d387.tar.bz2 luarocks-de978bfcc0b90600ab3a0e0d22e4fd7dd5a6d387.zip |
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.
-rw-r--r-- | src/luarocks/fs/lua.lua | 15 |
1 files changed, 14 insertions, 1 deletions
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) | |||
123 | ok = tool_available_cache[tool_name] | 123 | ok = tool_available_cache[tool_name] |
124 | else | 124 | else |
125 | local tool_cmd_no_args = tool_cmd:gsub(" .*", "") | 125 | local tool_cmd_no_args = tool_cmd:gsub(" .*", "") |
126 | ok = fs.search_in_path(tool_cmd_no_args) | 126 | |
127 | -- if it looks like the tool has a pathname, try that first | ||
128 | if tool_cmd_no_args:match("[/\\]") then | ||
129 | local fd = io.open(tool_cmd_no_args, "r") | ||
130 | if fd then | ||
131 | fd:close() | ||
132 | ok = true | ||
133 | end | ||
134 | end | ||
135 | |||
136 | if not ok then | ||
137 | ok = fs.search_in_path(tool_cmd_no_args) | ||
138 | end | ||
139 | |||
127 | tool_available_cache[tool_name] = (ok == true) | 140 | tool_available_cache[tool_name] = (ok == true) |
128 | end | 141 | end |
129 | 142 | ||