mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
system([...]): Set v:shell_error=-1 if not executable.
Do _not_ set v:shell_error on parameter validation error. system([...]) does not invoke a shell, so this change is somewhat questionable. But `:help v:shell_error` is sufficiently vague to allow -1 in this case.
This commit is contained in:
parent
4178e865d5
commit
1e079fa987
@ -16994,8 +16994,12 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
|
||||
}
|
||||
|
||||
// get shell command to execute
|
||||
char **argv = tv_to_argv(&argvars[0], NULL, NULL);
|
||||
bool executable = true;
|
||||
char **argv = tv_to_argv(&argvars[0], NULL, &executable);
|
||||
if (!argv) {
|
||||
if (!executable) {
|
||||
set_vim_var_nr(VV_SHELL_ERROR, (long)-1);
|
||||
}
|
||||
xfree(input);
|
||||
return; // Already did emsg.
|
||||
}
|
||||
|
@ -33,9 +33,15 @@ describe('system()', function()
|
||||
local printargs_path = helpers.nvim_dir..'/printargs-test'
|
||||
.. (helpers.os_name() == 'windows' and '.exe' or '')
|
||||
|
||||
it('sets v:shell_error if cmd[0] is not executable', function()
|
||||
call('system', { 'this-should-not-exist' })
|
||||
eq(-1, eval('v:shell_error'))
|
||||
end)
|
||||
|
||||
it('quotes arguments correctly #5280', function()
|
||||
local out = call('system',
|
||||
{ printargs_path, [[1]], [[2 "3]], [[4 ' 5]], [[6 ' 7']] })
|
||||
|
||||
eq(0, eval('v:shell_error'))
|
||||
eq([[arg1=1;arg2=2 "3;arg3=4 ' 5;arg4=6 ' 7';]], out)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user