summaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-06-19 19:59:20 +0200
committerBram Moolenaar <Bram@vim.org>2018-06-19 19:59:20 +0200
commitf9c3883b11b33f0c548df5e949ba59fde74d3e7b (patch)
treeab21fb8c95cc6f094925f89752989a41628a0be1 /src/os_unix.c
parent1ceebb4efc455dc6c34e0cd2c2adbd00939f038b (diff)
downloadvim-git-f9c3883b11b33f0c548df5e949ba59fde74d3e7b.tar.gz
patch 8.1.0087: v:shell_error is always zero when using terminal for "!cmd"v8.1.0087
Problem: v:shell_error is always zero when using terminal for "!cmd". Solution: Use "exitval" of terminal-job. (Ozaki Kiichi, closes #2994)
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 05ad6b8df..3649276c4 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -4365,6 +4365,7 @@ mch_call_shell_terminal(
char_u *tofree2 = NULL;
int retval = -1;
buf_T *buf;
+ job_T *job;
aco_save_T aco;
oparg_T oa; /* operator arguments */
@@ -4374,6 +4375,11 @@ mch_call_shell_terminal(
init_job_options(&opt);
ch_log(NULL, "starting terminal for system command '%s'", cmd);
buf = term_start(NULL, argv, &opt, TERM_START_SYSTEM);
+ if (buf == NULL)
+ goto theend;
+
+ job = term_getjob(buf->b_term);
+ ++job->jv_refcount;
/* Find a window to make "buf" curbuf. */
aucmd_prepbuf(&aco, buf);
@@ -4391,9 +4397,11 @@ mch_call_shell_terminal(
else
normal_cmd(&oa, TRUE);
}
- retval = 0;
+ retval = job->jv_exitval;
ch_log(NULL, "system command finished");
+ job_unref(job);
+
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);