aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/eval.c6
-rw-r--r--test/functional/eval/system_spec.lua6
2 files changed, 11 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 17e89e5757..1688a565c1 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -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.
}
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua
index 09497e85c2..bbbbdcd2ef 100644
--- a/test/functional/eval/system_spec.lua
+++ b/test/functional/eval/system_spec.lua
@@ -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)