aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-02-03 17:19:51 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-02-03 18:38:37 +0800
commita87ecf5d086c9a93be4c5f331a684301b2c1bc12 (patch)
treeeea089ddd8aae373ac45656e55e438ec63502a20
parent21cdecc8e0233d7a99d971327d21f701dbd65ba1 (diff)
downloadrneovim-a87ecf5d086c9a93be4c5f331a684301b2c1bc12.tar.gz
rneovim-a87ecf5d086c9a93be4c5f331a684301b2c1bc12.tar.bz2
rneovim-a87ecf5d086c9a93be4c5f331a684301b2c1bc12.zip
fix(health): do not run external processes in a shell
-rw-r--r--runtime/autoload/health/nvim.vim12
-rw-r--r--runtime/autoload/health/provider.vim18
-rw-r--r--test/functional/plugin/health_spec.lua11
3 files changed, 26 insertions, 15 deletions
diff --git a/runtime/autoload/health/nvim.vim b/runtime/autoload/health/nvim.vim
index ef680097d5..961f83d926 100644
--- a/runtime/autoload/health/nvim.vim
+++ b/runtime/autoload/health/nvim.vim
@@ -148,14 +148,14 @@ endfunction
function! s:get_tmux_option(option) abort
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')
if v:shell_error
call health#report_error('command failed: '.cmd."\n".out)
return 'error'
elseif empty(val)
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')
if v:shell_error
call health#report_error('command failed: '.cmd."\n".out)
@@ -202,11 +202,11 @@ function! s:check_tmux() abort
" check default-terminal and $TERM
call health#report_info('$TERM: '.$TERM)
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')
if empty(tmux_default_term)
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')
endif
@@ -225,7 +225,7 @@ function! s:check_tmux() abort
endif
" 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_rgb = stridx(info, " RGB: (flag) true") != -1
if !has_tc && !has_rgb
@@ -242,7 +242,7 @@ function! s:check_terminal() abort
endif
call health#report_start('terminal')
let cmd = 'infocmp -L'
- let out = system(cmd)
+ let out = system(split(cmd))
let kbs_entry = matchstr(out, 'key_backspace=[^,[:space:]]*')
let kdch1_entry = matchstr(out, 'key_dc=[^,[:space:]]*')
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index 8f0dbbab39..2f35179338 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -565,7 +565,7 @@ function! s:check_ruby() abort
\ ['Install Ruby and verify that `ruby` and `gem` commands work.'])
return
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()
if empty(host)
@@ -588,11 +588,11 @@ function! s:check_ruby() abort
endif
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)
if s:shell_error
- call health#report_error('Failed to run: '. current_gem_cmd,
- \ ['Report this issue with the output of: ', current_gem_cmd])
+ call health#report_error('Failed to run: '. join(current_gem_cmd),
+ \ ['Report this issue with the output of: ', join(current_gem_cmd)])
return
endif
@@ -619,7 +619,7 @@ function! s:check_node() abort
\ ['Install Node.js and verify that `node` and `npm` (or `yarn`) commands work.'])
return
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)
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)
@@ -660,8 +660,8 @@ function! s:check_node() abort
let current_npm_cmd = ['node', host, '--version']
let current_npm = s:system(current_npm_cmd)
if s:shell_error
- call health#report_error('Failed to run: '. string(current_npm_cmd),
- \ ['Report this issue with the output of: ', string(current_npm_cmd)])
+ call health#report_error('Failed to run: '. join(current_npm_cmd),
+ \ ['Report this issue with the output of: ', join(current_npm_cmd)])
return
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 = s:system(current_cpan_cmd)
if s:shell_error
- call health#report_error('Failed to run: '. string(current_cpan_cmd),
- \ ['Report this issue with the output of: ', string(current_cpan_cmd)])
+ call health#report_error('Failed to run: '. join(current_cpan_cmd),
+ \ ['Report this issue with the output of: ', join(current_cpan_cmd)])
return
endif
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
index 37de5d0ce6..f7c2dbdb43 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -230,3 +230,14 @@ describe('health.vim', function()
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)