diff src/os_win32.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 39ec4b90e4a7
children 2771a99db70c
line wrap: on
line diff
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -4796,6 +4796,7 @@ mch_call_shell_terminal(
     long_u	cmdlen;
     int		retval = -1;
     buf_T	*buf;
+    job_T	*job;
     aco_save_T	aco;
     oparg_T	oa;		/* operator arguments */
 
@@ -4826,6 +4827,9 @@ mch_call_shell_terminal(
     if (buf == NULL)
 	return 255;
 
+    job = term_getjob(buf->b_term);
+    ++job->jv_refcount;
+
     /* Find a window to make "buf" curbuf. */
     aucmd_prepbuf(&aco, buf);
 
@@ -4842,9 +4846,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);