mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 14:26:07 +00:00
vim-patch:8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Problem: MS-Windows: shell commands fail if &shell contains a space. Solution: Use quotes instead of escaping. (closes vim/vim#4920)2efc44b3f0
Always double-quote &shell if it contains a space. Neovim does not support escaping space with backslash, unlike Vim. N/A patches for version.c: vim-patch:8.0.1455: if $SHELL contains a space then 'shell' is incorrect Problem: If $SHELL contains a space then the default value of 'shell' is incorrect. (Matthew Horan) Solution: Escape spaces in $SHELL. (Christian Brabandt, closes vim/vim#459)4bfa8af141
vim-patch:8.2.1194: test failure because shell prompt differs Problem: Test failure because shell prompt differs. Solution: Set the shell prompt.a4dc6f92bb
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
" Tests for system() and systemlist()
|
||||
|
||||
source shared.vim
|
||||
source check.vim
|
||||
|
||||
function! Test_System()
|
||||
if !executable('echo') || !executable('cat') || !executable('wc')
|
||||
return
|
||||
@@ -88,3 +91,54 @@ function! Test_system_exmode()
|
||||
let a = system(v:progpath. cmd)
|
||||
call assert_notequal(0, v:shell_error)
|
||||
endfunc
|
||||
|
||||
func Test_system_with_shell_quote()
|
||||
throw 'skipped: enable after porting method patches'
|
||||
CheckMSWindows
|
||||
|
||||
call mkdir('Xdir with spaces', 'p')
|
||||
call system('copy "%COMSPEC%" "Xdir with spaces\cmd.exe"')
|
||||
|
||||
let shell_save = &shell
|
||||
let shellxquote_save = &shellxquote
|
||||
try
|
||||
" Set 'shell' always needs noshellslash.
|
||||
let shellslash_save = &shellslash
|
||||
set noshellslash
|
||||
let shell_tests = [
|
||||
\ expand('$COMSPEC'),
|
||||
\ '"' . fnamemodify('Xdir with spaces\cmd.exe', ':p') . '"',
|
||||
\]
|
||||
let &shellslash = shellslash_save
|
||||
|
||||
let sxq_tests = ['', '(', '"']
|
||||
|
||||
" Matrix tests: 'shell' * 'shellxquote'
|
||||
for shell in shell_tests
|
||||
let &shell = shell
|
||||
for sxq in sxq_tests
|
||||
let &shellxquote = sxq
|
||||
|
||||
let msg = printf('shell=%s shellxquote=%s', &shell, &shellxquote)
|
||||
|
||||
try
|
||||
let out = 'echo 123'->system()
|
||||
catch
|
||||
call assert_report(printf('%s: %s', msg, v:exception))
|
||||
continue
|
||||
endtry
|
||||
|
||||
" On Windows we may get a trailing space and CR.
|
||||
if out != "123 \n"
|
||||
call assert_equal("123\n", out, msg)
|
||||
endif
|
||||
|
||||
endfor
|
||||
endfor
|
||||
|
||||
finally
|
||||
let &shell = shell_save
|
||||
let &shellxquote = shellxquote_save
|
||||
call delete('Xdir with spaces', 'rf')
|
||||
endtry
|
||||
endfunc
|
||||
|
Reference in New Issue
Block a user