diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ba5864fe3b..a791fea663 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11608,9 +11608,6 @@ static char **tv_to_argv(typval_T *cmd_tv, char **cmd) const char_u *exe = get_tv_string_chk(&argl->lv_first->li_tv); if (!exe || !os_can_exe(exe, NULL, true)) { // String is not executable - if (exe) { - EMSG2(e_jobexe, exe); - } return NULL; } @@ -11646,6 +11643,7 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr) char **argv = tv_to_argv(&argvars[0], NULL); if (!argv) { + rettv->vval.v_number = -1; // Return -1 on error. return; // Did error message in tv_to_argv. } @@ -16470,6 +16468,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) char *cmd; char **argv = tv_to_argv(&argvars[0], &cmd); if (!argv) { + rettv->vval.v_number = -1; // Return -1 on error. return; // Did error message in tv_to_argv. } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index f81fb43eaf..acdda9b657 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1125,7 +1125,6 @@ EXTERN char_u e_invcmd[] INIT(= N_("E476: Invalid command")); EXTERN char_u e_isadir2[] INIT(= N_("E17: \"%s\" is a directory")); EXTERN char_u e_invjob[] INIT(= N_("E900: Invalid job id")); EXTERN char_u e_jobtblfull[] INIT(= N_("E901: Job table is full")); -EXTERN char_u e_jobexe[] INIT(= N_("E902: \"%s\" is not an executable")); EXTERN char_u e_jobspawn[] INIT(= N_( "E903: Process for command \"%s\" could not be spawned")); EXTERN char_u e_jobnotpty[] INIT(= N_("E904: Job is not connected to a pty")); diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 9d24ba62db..61bd4f8b44 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -70,6 +70,12 @@ describe('jobs', function() ok(rv ~= nil) end) + it('returns -1 when target is not executable', function() + local rv = eval("jobstart(['./test/functional/fixtures/non_executable.txt'])") + eq(-1, rv) + eq("", eval("v:errmsg")) + end) + it('invokes callbacks when the job writes and exits', function() nvim('command', "call jobstart(['echo'], g:job_opts)") eq({'notification', 'stdout', {0, {'', ''}}}, next_msg()) diff --git a/test/functional/fixtures/non_executable.txt b/test/functional/fixtures/non_executable.txt new file mode 100644 index 0000000000..cc27ecc664 --- /dev/null +++ b/test/functional/fixtures/non_executable.txt @@ -0,0 +1 @@ +This file is not an executable