mirror of
https://github.com/neovim/neovim.git
synced 2025-12-11 09:02:40 +00:00
fix(health): do not run external processes in a shell
This commit is contained in:
@@ -148,14 +148,14 @@ endfunction
|
|||||||
|
|
||||||
function! s:get_tmux_option(option) abort
|
function! s:get_tmux_option(option) abort
|
||||||
let cmd = 'tmux show-option -qvg '.a:option " try global scope
|
let cmd = 'tmux show-option -qvg '.a:option " try global scope
|
||||||
let out = system(cmd)
|
let out = system(split(cmd))
|
||||||
let val = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
let val = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
call health#report_error('command failed: '.cmd."\n".out)
|
call health#report_error('command failed: '.cmd."\n".out)
|
||||||
return 'error'
|
return 'error'
|
||||||
elseif empty(val)
|
elseif empty(val)
|
||||||
let cmd = 'tmux show-option -qvgs '.a:option " try session scope
|
let cmd = 'tmux show-option -qvgs '.a:option " try session scope
|
||||||
let out = system(cmd)
|
let out = system(split(cmd))
|
||||||
let val = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
let val = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
call health#report_error('command failed: '.cmd."\n".out)
|
call health#report_error('command failed: '.cmd."\n".out)
|
||||||
@@ -202,11 +202,11 @@ function! s:check_tmux() abort
|
|||||||
" check default-terminal and $TERM
|
" check default-terminal and $TERM
|
||||||
call health#report_info('$TERM: '.$TERM)
|
call health#report_info('$TERM: '.$TERM)
|
||||||
let cmd = 'tmux show-option -qvg default-terminal'
|
let cmd = 'tmux show-option -qvg default-terminal'
|
||||||
let out = system(cmd)
|
let out = system(split(cmd))
|
||||||
let tmux_default_term = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
let tmux_default_term = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
||||||
if empty(tmux_default_term)
|
if empty(tmux_default_term)
|
||||||
let cmd = 'tmux show-option -qvgs default-terminal'
|
let cmd = 'tmux show-option -qvgs default-terminal'
|
||||||
let out = system(cmd)
|
let out = system(split(cmd))
|
||||||
let tmux_default_term = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
let tmux_default_term = substitute(out, '\v(\s|\r|\n)', '', 'g')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ function! s:check_tmux() abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" check for RGB capabilities
|
" check for RGB capabilities
|
||||||
let info = system('tmux server-info')
|
let info = system(['tmux', 'server-info'])
|
||||||
let has_tc = stridx(info, " Tc: (flag) true") != -1
|
let has_tc = stridx(info, " Tc: (flag) true") != -1
|
||||||
let has_rgb = stridx(info, " RGB: (flag) true") != -1
|
let has_rgb = stridx(info, " RGB: (flag) true") != -1
|
||||||
if !has_tc && !has_rgb
|
if !has_tc && !has_rgb
|
||||||
@@ -242,7 +242,7 @@ function! s:check_terminal() abort
|
|||||||
endif
|
endif
|
||||||
call health#report_start('terminal')
|
call health#report_start('terminal')
|
||||||
let cmd = 'infocmp -L'
|
let cmd = 'infocmp -L'
|
||||||
let out = system(cmd)
|
let out = system(split(cmd))
|
||||||
let kbs_entry = matchstr(out, 'key_backspace=[^,[:space:]]*')
|
let kbs_entry = matchstr(out, 'key_backspace=[^,[:space:]]*')
|
||||||
let kdch1_entry = matchstr(out, 'key_dc=[^,[:space:]]*')
|
let kdch1_entry = matchstr(out, 'key_dc=[^,[:space:]]*')
|
||||||
|
|
||||||
|
|||||||
@@ -565,7 +565,7 @@ function! s:check_ruby() abort
|
|||||||
\ ['Install Ruby and verify that `ruby` and `gem` commands work.'])
|
\ ['Install Ruby and verify that `ruby` and `gem` commands work.'])
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
call health#report_info('Ruby: '. s:system('ruby -v'))
|
call health#report_info('Ruby: '. s:system(['ruby', '-v']))
|
||||||
|
|
||||||
let [host, err] = provider#ruby#Detect()
|
let [host, err] = provider#ruby#Detect()
|
||||||
if empty(host)
|
if empty(host)
|
||||||
@@ -588,11 +588,11 @@ function! s:check_ruby() abort
|
|||||||
endif
|
endif
|
||||||
let latest_gem = get(split(latest_gem, 'neovim (\|, \|)$' ), 0, 'not found')
|
let latest_gem = get(split(latest_gem, 'neovim (\|, \|)$' ), 0, 'not found')
|
||||||
|
|
||||||
let current_gem_cmd = host .' --version'
|
let current_gem_cmd = [host, '--version']
|
||||||
let current_gem = s:system(current_gem_cmd)
|
let current_gem = s:system(current_gem_cmd)
|
||||||
if s:shell_error
|
if s:shell_error
|
||||||
call health#report_error('Failed to run: '. current_gem_cmd,
|
call health#report_error('Failed to run: '. join(current_gem_cmd),
|
||||||
\ ['Report this issue with the output of: ', current_gem_cmd])
|
\ ['Report this issue with the output of: ', join(current_gem_cmd)])
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -619,7 +619,7 @@ function! s:check_node() abort
|
|||||||
\ ['Install Node.js and verify that `node` and `npm` (or `yarn`) commands work.'])
|
\ ['Install Node.js and verify that `node` and `npm` (or `yarn`) commands work.'])
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let node_v = get(split(s:system('node -v'), "\n"), 0, '')
|
let node_v = get(split(s:system(['node', '-v']), "\n"), 0, '')
|
||||||
call health#report_info('Node.js: '. node_v)
|
call health#report_info('Node.js: '. node_v)
|
||||||
if s:shell_error || s:version_cmp(node_v[1:], '6.0.0') < 0
|
if s:shell_error || s:version_cmp(node_v[1:], '6.0.0') < 0
|
||||||
call health#report_warn('Nvim node.js host does not support '.node_v)
|
call health#report_warn('Nvim node.js host does not support '.node_v)
|
||||||
@@ -660,8 +660,8 @@ function! s:check_node() abort
|
|||||||
let current_npm_cmd = ['node', host, '--version']
|
let current_npm_cmd = ['node', host, '--version']
|
||||||
let current_npm = s:system(current_npm_cmd)
|
let current_npm = s:system(current_npm_cmd)
|
||||||
if s:shell_error
|
if s:shell_error
|
||||||
call health#report_error('Failed to run: '. string(current_npm_cmd),
|
call health#report_error('Failed to run: '. join(current_npm_cmd),
|
||||||
\ ['Report this issue with the output of: ', string(current_npm_cmd)])
|
\ ['Report this issue with the output of: ', join(current_npm_cmd)])
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -734,8 +734,8 @@ function! s:check_perl() abort
|
|||||||
let current_cpan_cmd = [perl_exec, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION']
|
let current_cpan_cmd = [perl_exec, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION']
|
||||||
let current_cpan = s:system(current_cpan_cmd)
|
let current_cpan = s:system(current_cpan_cmd)
|
||||||
if s:shell_error
|
if s:shell_error
|
||||||
call health#report_error('Failed to run: '. string(current_cpan_cmd),
|
call health#report_error('Failed to run: '. join(current_cpan_cmd),
|
||||||
\ ['Report this issue with the output of: ', string(current_cpan_cmd)])
|
\ ['Report this issue with the output of: ', join(current_cpan_cmd)])
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -230,3 +230,14 @@ describe('health.vim', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe(':checkhealth provider', function()
|
||||||
|
it("works correctly with a wrongly configured 'shell'", function()
|
||||||
|
clear()
|
||||||
|
command([[set shell=echo\ WRONG!!!]])
|
||||||
|
command('let g:loaded_perl_provider = 0')
|
||||||
|
command('let g:loaded_python3_provider = 0')
|
||||||
|
command('checkhealth provider')
|
||||||
|
eq(nil, string.match(curbuf_contents(), 'WRONG!!!'))
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user