@@ -462,7 +462,7 @@ term_start(typval_T *argvar, jobopt_T *opt, int forceit)
462462 void
463463ex_terminal (exarg_T * eap )
464464{
465- typval_T argvar ;
465+ typval_T argvar [ 2 ] ;
466466 jobopt_T opt ;
467467 char_u * cmd ;
468468 char_u * tofree = NULL ;
@@ -525,8 +525,8 @@ ex_terminal(exarg_T *eap)
525525 }
526526 cmd = skipwhite (p );
527527 }
528- if (cmd == NULL || * cmd == NUL )
529- /* Make a copy, an autocommand may set 'shell' . */
528+ if (* cmd == NUL )
529+ /* Make a copy of 'shell' , an autocommand may change the option . */
530530 tofree = cmd = vim_strsave (p_sh );
531531
532532 if (eap -> addr_count > 0 )
@@ -539,9 +539,10 @@ ex_terminal(exarg_T *eap)
539539 opt .jo_in_bot = eap -> line2 ;
540540 }
541541
542- argvar .v_type = VAR_STRING ;
543- argvar .vval .v_string = cmd ;
544- term_start (& argvar , & opt , eap -> forceit );
542+ argvar [0 ].v_type = VAR_STRING ;
543+ argvar [0 ].vval .v_string = cmd ;
544+ argvar [1 ].v_type = VAR_UNKNOWN ;
545+ term_start (argvar , & opt , eap -> forceit );
545546 vim_free (tofree );
546547}
547548
@@ -2886,7 +2887,8 @@ f_term_wait(typval_T *argvars, typval_T *rettv UNUSED)
28862887 && STRCMP (job_status (buf -> b_term -> tl_job ), "dead" ) == 0 )
28872888 {
28882889 /* The job is dead, keep reading channel I/O until the channel is
2889- * closed. */
2890+ * closed. buf->b_term may become NULL if the terminal was closed while
2891+ * waiting. */
28902892 ch_log (NULL , "term_wait(): waiting for channel to close" );
28912893 while (buf -> b_term != NULL && !buf -> b_term -> tl_channel_closed )
28922894 {
0 commit comments