mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
Merge pull request #11148 from janlazo/vim-8.0.1455
vim-patch:8.0.1455,8.1.{2115,2361}
This commit is contained in:
@@ -5166,6 +5166,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
It is allowed to give an argument to the command, e.g. "csh -f".
|
It is allowed to give an argument to the command, e.g. "csh -f".
|
||||||
See |option-backslash| about including spaces and backslashes.
|
See |option-backslash| about including spaces and backslashes.
|
||||||
Environment variables are expanded |:set_env|.
|
Environment variables are expanded |:set_env|.
|
||||||
|
|
||||||
If the name of the shell contains a space, you might need to enclose
|
If the name of the shell contains a space, you might need to enclose
|
||||||
it in quotes. Example: >
|
it in quotes. Example: >
|
||||||
:set shell=\"c:\program\ files\unix\sh.exe\"\ -f
|
:set shell=\"c:\program\ files\unix\sh.exe\"\ -f
|
||||||
|
@@ -1182,6 +1182,7 @@ static void do_filter(
|
|||||||
char_u *cmd_buf;
|
char_u *cmd_buf;
|
||||||
buf_T *old_curbuf = curbuf;
|
buf_T *old_curbuf = curbuf;
|
||||||
int shell_flags = 0;
|
int shell_flags = 0;
|
||||||
|
const int stmp = p_stmp;
|
||||||
|
|
||||||
if (*cmd == NUL) /* no filter command */
|
if (*cmd == NUL) /* no filter command */
|
||||||
return;
|
return;
|
||||||
@@ -1210,16 +1211,16 @@ static void do_filter(
|
|||||||
if (do_out)
|
if (do_out)
|
||||||
shell_flags |= kShellOptDoOut;
|
shell_flags |= kShellOptDoOut;
|
||||||
|
|
||||||
if (!do_in && do_out && !p_stmp) {
|
if (!do_in && do_out && !stmp) {
|
||||||
// Use a pipe to fetch stdout of the command, do not use a temp file.
|
// Use a pipe to fetch stdout of the command, do not use a temp file.
|
||||||
shell_flags |= kShellOptRead;
|
shell_flags |= kShellOptRead;
|
||||||
curwin->w_cursor.lnum = line2;
|
curwin->w_cursor.lnum = line2;
|
||||||
} else if (do_in && !do_out && !p_stmp) {
|
} else if (do_in && !do_out && !stmp) {
|
||||||
// Use a pipe to write stdin of the command, do not use a temp file.
|
// Use a pipe to write stdin of the command, do not use a temp file.
|
||||||
shell_flags |= kShellOptWrite;
|
shell_flags |= kShellOptWrite;
|
||||||
curbuf->b_op_start.lnum = line1;
|
curbuf->b_op_start.lnum = line1;
|
||||||
curbuf->b_op_end.lnum = line2;
|
curbuf->b_op_end.lnum = line2;
|
||||||
} else if (do_in && do_out && !p_stmp) {
|
} else if (do_in && do_out && !stmp) {
|
||||||
// Use a pipe to write stdin and fetch stdout of the command, do not
|
// Use a pipe to write stdin and fetch stdout of the command, do not
|
||||||
// use a temp file.
|
// use a temp file.
|
||||||
shell_flags |= kShellOptRead | kShellOptWrite;
|
shell_flags |= kShellOptRead | kShellOptWrite;
|
||||||
|
@@ -652,7 +652,14 @@ void set_init_1(bool clean_arg)
|
|||||||
{
|
{
|
||||||
const char *shell = os_getenv("SHELL");
|
const char *shell = os_getenv("SHELL");
|
||||||
if (shell != NULL) {
|
if (shell != NULL) {
|
||||||
set_string_default("sh", (char *) shell, false);
|
if (vim_strchr((const char_u *)shell, ' ') != NULL) {
|
||||||
|
const size_t len = strlen(shell) + 3; // two quotes and a trailing NUL
|
||||||
|
char *const cmd = xmalloc(len);
|
||||||
|
snprintf(cmd, len, "\"%s\"", shell);
|
||||||
|
set_string_default("sh", cmd, true);
|
||||||
|
} else {
|
||||||
|
set_string_default("sh", (char *)shell, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -987,10 +994,9 @@ static void set_string_default(const char *name, char *val, bool allocated)
|
|||||||
xfree(options[opt_idx].def_val[VI_DEFAULT]);
|
xfree(options[opt_idx].def_val[VI_DEFAULT]);
|
||||||
}
|
}
|
||||||
|
|
||||||
options[opt_idx].def_val[VI_DEFAULT] = (char_u *) (
|
options[opt_idx].def_val[VI_DEFAULT] = allocated
|
||||||
allocated
|
? (char_u *)val
|
||||||
? (char_u *) val
|
: (char_u *)xstrdup(val);
|
||||||
: (char_u *) xstrdup(val));
|
|
||||||
options[opt_idx].flags |= P_DEF_ALLOCED;
|
options[opt_idx].flags |= P_DEF_ALLOCED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -516,7 +516,7 @@ func Test_termguicolors()
|
|||||||
if !exists('+termguicolors')
|
if !exists('+termguicolors')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
if has('vtp') && !has('vcon')
|
if has('vtp') && !has('vcon') && !has('gui_running')
|
||||||
" Win32: 'guicolors' doesn't work without virtual console.
|
" Win32: 'guicolors' doesn't work without virtual console.
|
||||||
call assert_fails('set termguicolors', 'E954:')
|
call assert_fails('set termguicolors', 'E954:')
|
||||||
return
|
return
|
||||||
|
@@ -581,6 +581,27 @@ func Test_read_stdin()
|
|||||||
call delete('Xtestout')
|
call delete('Xtestout')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_set_shell()
|
||||||
|
let after =<< trim [CODE]
|
||||||
|
call writefile([&shell], "Xtestout")
|
||||||
|
quit!
|
||||||
|
[CODE]
|
||||||
|
|
||||||
|
if has('win32')
|
||||||
|
let $SHELL = 'C:\with space\cmd.exe'
|
||||||
|
let expected = '"C:\with space\cmd.exe"'
|
||||||
|
else
|
||||||
|
let $SHELL = '/bin/with space/sh'
|
||||||
|
let expected = '"/bin/with space/sh"'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if RunVimPiped([], after, '', '')
|
||||||
|
let lines = readfile('Xtestout')
|
||||||
|
call assert_equal(expected, lines[0])
|
||||||
|
endif
|
||||||
|
call delete('Xtestout')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_progpath()
|
func Test_progpath()
|
||||||
" Tests normally run with "./vim" or "../vim", these must have been expanded
|
" Tests normally run with "./vim" or "../vim", these must have been expanded
|
||||||
" to a full path.
|
" to a full path.
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
" Tests for system() and systemlist()
|
" Tests for system() and systemlist()
|
||||||
|
|
||||||
|
source shared.vim
|
||||||
|
source check.vim
|
||||||
|
|
||||||
function! Test_System()
|
function! Test_System()
|
||||||
if !executable('echo') || !executable('cat') || !executable('wc')
|
if !executable('echo') || !executable('cat') || !executable('wc')
|
||||||
return
|
return
|
||||||
@@ -88,3 +91,54 @@ function! Test_system_exmode()
|
|||||||
let a = system(v:progpath. cmd)
|
let a = system(v:progpath. cmd)
|
||||||
call assert_notequal(0, v:shell_error)
|
call assert_notequal(0, v:shell_error)
|
||||||
endfunc
|
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