Patch 8.1.2251
Problem:    ":term command" may not work without a shell.
Solution:   Add the ++shell option to :term. (closes #3340)
Files:      runtime/doc/terminal.txt, src/terminal.c,
            src/os_unix.c, src/proto/os_unix.pro,
            src/testdir/test_terminal.vim


*** ../vim-8.1.2250/runtime/doc/terminal.txt    2019-10-20 21:15:07.457905609 
+0200
--- runtime/doc/terminal.txt    2019-11-03 23:36:29.993161387 +0100
***************
*** 210,215 ****
--- 210,219 ----
                                        no window will be used.
                        ++norestore     Do not include this terminal window
                                        in a session file.
+                       ++shell         Instead of executing {command}
+                                       directly, use a shell, like with
+                                       `:!command`             *E279*
+                                       {only works on Unix currently}
                        ++kill={how}    When trying to close the terminal
                                        window kill the job with {how}.  See
                                        |term_setkill()| for the values.
*** ../vim-8.1.2250/src/terminal.c      2019-11-03 21:19:38.080721214 +0100
--- src/terminal.c      2019-11-03 23:21:35.669530139 +0100
***************
*** 703,708 ****
--- 703,709 ----
  {
      typval_T  argvar[2];
      jobopt_T  opt;
+     int               opt_shell = FALSE;
      char_u    *cmd;
      char_u    *tofree = NULL;
  
***************
*** 738,743 ****
--- 739,746 ----
            opt.jo_hidden = 1;
        else if (OPTARG_HAS("norestore"))
            opt.jo_term_norestore = 1;
+       else if (OPTARG_HAS("shell"))
+           opt_shell = TRUE;
        else if (OPTARG_HAS("kill") && ep != NULL)
        {
            opt.jo_set2 |= JO2_TERM_KILL;
***************
*** 831,840 ****
        opt.jo_in_bot = eap->line2;
      }
  
!     argvar[0].v_type = VAR_STRING;
!     argvar[0].vval.v_string = cmd;
!     argvar[1].v_type = VAR_UNKNOWN;
!     term_start(argvar, NULL, &opt, eap->forceit ? TERM_START_FORCEIT : 0);
      vim_free(tofree);
  
  theend:
--- 834,863 ----
        opt.jo_in_bot = eap->line2;
      }
  
!     if (opt_shell && tofree == NULL)
!     {
! #ifdef UNIX
!       char    **argv = NULL;
!       char_u  *tofree1 = NULL;
!       char_u  *tofree2 = NULL;
! 
!       // :term ++shell command
!       if (unix_build_argv(cmd, &argv, &tofree1, &tofree2) == OK)
!           term_start(NULL, argv, &opt, eap->forceit ? TERM_START_FORCEIT : 0);
!       vim_free(tofree1);
!       vim_free(tofree2);
! #else
!       emsg(_("E279: Sorry, ++shell is not supported on this system"));
! #endif
!     }
!     else
!     {
!       argvar[0].v_type = VAR_STRING;
!       argvar[0].vval.v_string = cmd;
!       argvar[1].v_type = VAR_UNKNOWN;
!       term_start(argvar, NULL, &opt, eap->forceit ? TERM_START_FORCEIT : 0);
!     }
! 
      vim_free(tofree);
  
  theend:
***************
*** 6474,6480 ****
  term_and_job_init(
        term_T      *term,
        typval_T    *argvar,
!       char        **argv UNUSED,
        jobopt_T    *opt,
        jobopt_T    *orig_opt)
  {
--- 6497,6503 ----
  term_and_job_init(
        term_T      *term,
        typval_T    *argvar,
!       char        **argv,
        jobopt_T    *opt,
        jobopt_T    *orig_opt)
  {
*** ../vim-8.1.2250/src/os_unix.c       2019-11-02 22:54:37.405188813 +0100
--- src/os_unix.c       2019-11-03 23:20:57.381685076 +0100
***************
*** 4299,4308 ****
  # endif
  }
  
! #if !defined(USE_SYSTEM) || (defined(FEAT_GUI) && defined(FEAT_TERMINAL))
  
!     static int
! build_argv(
        char_u *cmd,
        char ***argvp,
        char_u **sh_tofree,
--- 4299,4308 ----
  # endif
  }
  
! #if !defined(USE_SYSTEM) || defined(FEAT_TERMINAL) || defined(PROTO)
  
!     int
! unix_build_argv(
        char_u *cmd,
        char ***argvp,
        char_u **sh_tofree,
***************
*** 4369,4375 ****
      aco_save_T        aco;
      oparg_T   oa;             /* operator arguments */
  
!     if (build_argv(cmd, &argv, &tofree1, &tofree2) == FAIL)
        goto theend;
  
      init_job_options(&opt);
--- 4369,4375 ----
      aco_save_T        aco;
      oparg_T   oa;             /* operator arguments */
  
!     if (unix_build_argv(cmd, &argv, &tofree1, &tofree2) == FAIL)
        goto theend;
  
      init_job_options(&opt);
***************
*** 4546,4552 ****
      if (options & SHELL_COOKED)
        settmode(TMODE_COOK);           /* set to normal mode */
  
!     if (build_argv(cmd, &argv, &tofree1, &tofree2) == FAIL)
        goto error;
  
      /*
--- 4546,4552 ----
      if (options & SHELL_COOKED)
        settmode(TMODE_COOK);           /* set to normal mode */
  
!     if (unix_build_argv(cmd, &argv, &tofree1, &tofree2) == FAIL)
        goto error;
  
      /*
*** ../vim-8.1.2250/src/proto/os_unix.pro       2019-09-10 21:27:15.175646978 
+0200
--- src/proto/os_unix.pro       2019-11-03 23:21:02.201665551 +0100
***************
*** 59,64 ****
--- 59,65 ----
  int mch_report_winsize(int fd, int rows, int cols);
  void mch_set_shellsize(void);
  void mch_new_shellsize(void);
+ int unix_build_argv(char_u *cmd, char ***argvp, char_u **sh_tofree, char_u 
**shcf_tofree);
  int mch_call_shell(char_u *cmd, int options);
  void mch_job_start(char **argv, job_T *job, jobopt_T *options, int 
is_terminal);
  char *mch_job_status(job_T *job);
*** ../vim-8.1.2250/src/testdir/test_terminal.vim       2019-10-28 
00:42:17.645477101 +0100
--- src/testdir/test_terminal.vim       2019-11-03 23:32:22.914755807 +0100
***************
*** 2214,2219 ****
--- 2214,2231 ----
    call delete('Xtext')
  endfunc
  
+ func Test_terminal_shell_option()
+   CheckUnix
+   " exec is a shell builtin command, should fail without a shell.
+   term exec ls runtest.vim
+   call WaitForAssert({-> assert_match('job failed', term_getline(bufnr(), 
1))})
+   bwipe!
+ 
+   term ++shell exec ls runtest.vim
+   call WaitForAssert({-> assert_match('runtest.vim', term_getline(bufnr(), 
1))})
+   bwipe!
+ endfunc
+ 
  func Test_terminal_setapi_and_call()
    if !CanRunVimInTerminal()
      return
*** ../vim-8.1.2250/src/version.c       2019-11-03 22:29:19.469793561 +0100
--- src/version.c       2019-11-03 23:35:18.229599630 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     2251,
  /**/

-- 
How To Keep A Healthy Level Of Insanity:
17. When the money comes out the ATM, scream "I won!, I won! 3rd
    time this week!!!!!"

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201911032237.xA3Mbfaf016074%40masaka.moolenaar.net.

Raspunde prin e-mail lui