comparison src/os_unix.c @ 14139:4d3f6bf86bec v8.1.0087

patch 8.1.0087: v:shell_error is always zero when using terminal for "!cmd" commit https://github.com/vim/vim/commit/f9c3883b11b33f0c548df5e949ba59fde74d3e7b Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 19 19:59:20 2018 +0200 patch 8.1.0087: v:shell_error is always zero when using terminal for "!cmd" Problem: v:shell_error is always zero when using terminal for "!cmd". Solution: Use "exitval" of terminal-job. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/2994)
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Jun 2018 20:00:08 +0200
parents a9b141cf99ff
children 65b222617852
comparison
equal deleted inserted replaced
14138:aa8127dba7d0 14139:4d3f6bf86bec
4363 char **argv = NULL; 4363 char **argv = NULL;
4364 char_u *tofree1 = NULL; 4364 char_u *tofree1 = NULL;
4365 char_u *tofree2 = NULL; 4365 char_u *tofree2 = NULL;
4366 int retval = -1; 4366 int retval = -1;
4367 buf_T *buf; 4367 buf_T *buf;
4368 job_T *job;
4368 aco_save_T aco; 4369 aco_save_T aco;
4369 oparg_T oa; /* operator arguments */ 4370 oparg_T oa; /* operator arguments */
4370 4371
4371 if (build_argv(cmd, &argv, &tofree1, &tofree2) == FAIL) 4372 if (build_argv(cmd, &argv, &tofree1, &tofree2) == FAIL)
4372 goto theend; 4373 goto theend;
4373 4374
4374 init_job_options(&opt); 4375 init_job_options(&opt);
4375 ch_log(NULL, "starting terminal for system command '%s'", cmd); 4376 ch_log(NULL, "starting terminal for system command '%s'", cmd);
4376 buf = term_start(NULL, argv, &opt, TERM_START_SYSTEM); 4377 buf = term_start(NULL, argv, &opt, TERM_START_SYSTEM);
4378 if (buf == NULL)
4379 goto theend;
4380
4381 job = term_getjob(buf->b_term);
4382 ++job->jv_refcount;
4377 4383
4378 /* Find a window to make "buf" curbuf. */ 4384 /* Find a window to make "buf" curbuf. */
4379 aucmd_prepbuf(&aco, buf); 4385 aucmd_prepbuf(&aco, buf);
4380 4386
4381 clear_oparg(&oa); 4387 clear_oparg(&oa);
4389 normal_cmd(&oa, TRUE); 4395 normal_cmd(&oa, TRUE);
4390 } 4396 }
4391 else 4397 else
4392 normal_cmd(&oa, TRUE); 4398 normal_cmd(&oa, TRUE);
4393 } 4399 }
4394 retval = 0; 4400 retval = job->jv_exitval;
4395 ch_log(NULL, "system command finished"); 4401 ch_log(NULL, "system command finished");
4402
4403 job_unref(job);
4396 4404
4397 /* restore curwin/curbuf and a few other things */ 4405 /* restore curwin/curbuf and a few other things */
4398 aucmd_restbuf(&aco); 4406 aucmd_restbuf(&aco);
4399 4407
4400 wait_return(TRUE); 4408 wait_return(TRUE);