@@ -2,19 +2,17 @@ local scanner = {}
22
33-- Helper functions
44local function execute_command (cmd )
5- local handle = io.popen (cmd .. " 2>&1" )
6- if handle == nil then
7- return false , - 1 , " "
5+ print (cmd )
6+
7+ if cmd == nil then
8+ return false , - 1 , nil
89 end
9- local result = handle : read ( " *a " )
10+ local result = vim . system ( cmd , { text = true }): wait ( )
1011 if result == nil then
11- result = " "
12- end
13- local success , exit_code = handle :close ()
14- if success == nil then
15- return false , exit_code or - 1 , result
12+ return false , - 1 , nil
1613 end
17- return true , 0 , result
14+ print (result .stdout )
15+ return true , result .code , result .stdout
1816end
1917
2018local function split_path (path_env )
@@ -27,7 +25,7 @@ local function split_path(path_env)
2725end
2826
2927local function get_gcc_version (gcc_path )
30- local success , exit_code , output = execute_command (' " ' .. gcc_path .. ' " --version' )
28+ local success , exit_code , output = execute_command ({ " gcc " , " --version" } )
3129 if output == nil then
3230 return nil
3331 end
@@ -38,7 +36,8 @@ local function get_gcc_version(gcc_path)
3836end
3937
4038local function get_clang_version (clang_path )
41- local success , exit_code , output = execute_command (' "' .. clang_path .. ' " --version ' )
39+ local success , exit_code , output = execute_command ({ " clang" , " --version" })
40+
4241 if output == nil then
4342 return nil
4443 end
0 commit comments