@@ -37,13 +37,17 @@ function M.have(cmd, opts)
37
37
for _ , c in ipairs (cmd ) do
38
38
if vim .fn .executable (c ) == 1 then
39
39
local version = vim .fn .system (c .. " " .. opts .version ) or " "
40
- version = vim .trim (vim .split (version , " \n " )[1 ])
41
- version = version :gsub (" ^%s*" .. vim .pesc (c ) .. " %s*" , " " )
42
- if opts .version_pattern and not version :find (opts .version_pattern , 1 , true ) then
43
- opts .warn ((" `%s` version `%s` needed, but found `%s`" ):format (c , opts .version_pattern , version ))
40
+ if vim .v .shell_error ~= 0 then
41
+ opts .error ((" failed to get version of {%s}\n %s" ):format (c , version ))
44
42
else
45
- found = (" {%s} `%s`" ):format (c , version )
46
- break
43
+ version = vim .trim (vim .split (version , " \n " )[1 ])
44
+ version = version :gsub (" ^%s*" .. vim .pesc (c ) .. " %s*" , " " )
45
+ if opts .version_pattern and not version :find (opts .version_pattern , 1 , true ) then
46
+ opts .warn ((" `%s` version `%s` needed, but found `%s`" ):format (c , opts .version_pattern , version ))
47
+ else
48
+ found = (" {%s} `%s`" ):format (c , version )
49
+ break
50
+ end
47
51
end
48
52
end
49
53
end
0 commit comments