comparison src/terminal.c @ 18514:39b0c28fe495 v8.1.2251

patch 8.1.2251: ":term command" may not work without a shell Commit: https://github.com/vim/vim/commit/197c6b7da3ad4c3e3942a553f5dbc35722a4a349 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Nov 3 23:37:12 2019 +0100 patch 8.1.2251: ":term command" may not work without a shell Problem: ":term command" may not work without a shell. Solution: Add the ++shell option to :term. (closes https://github.com/vim/vim/issues/3340)
author Bram Moolenaar <Bram@vim.org>
date Sun, 03 Nov 2019 23:45:03 +0100
parents 3cd689e9eb7f
children dfdc29643c91
comparison
equal deleted inserted replaced
18513:5a62159b9a48 18514:39b0c28fe495
701 void 701 void
702 ex_terminal(exarg_T *eap) 702 ex_terminal(exarg_T *eap)
703 { 703 {
704 typval_T argvar[2]; 704 typval_T argvar[2];
705 jobopt_T opt; 705 jobopt_T opt;
706 int opt_shell = FALSE;
706 char_u *cmd; 707 char_u *cmd;
707 char_u *tofree = NULL; 708 char_u *tofree = NULL;
708 709
709 init_job_options(&opt); 710 init_job_options(&opt);
710 711
736 opt.jo_curwin = 1; 737 opt.jo_curwin = 1;
737 else if (OPTARG_HAS("hidden")) 738 else if (OPTARG_HAS("hidden"))
738 opt.jo_hidden = 1; 739 opt.jo_hidden = 1;
739 else if (OPTARG_HAS("norestore")) 740 else if (OPTARG_HAS("norestore"))
740 opt.jo_term_norestore = 1; 741 opt.jo_term_norestore = 1;
742 else if (OPTARG_HAS("shell"))
743 opt_shell = TRUE;
741 else if (OPTARG_HAS("kill") && ep != NULL) 744 else if (OPTARG_HAS("kill") && ep != NULL)
742 { 745 {
743 opt.jo_set2 |= JO2_TERM_KILL; 746 opt.jo_set2 |= JO2_TERM_KILL;
744 opt.jo_term_kill = ep + 1; 747 opt.jo_term_kill = ep + 1;
745 p = skiptowhite(cmd); 748 p = skiptowhite(cmd);
829 opt.jo_io_buf[PART_IN] = curbuf->b_fnum; 832 opt.jo_io_buf[PART_IN] = curbuf->b_fnum;
830 opt.jo_in_top = eap->line1; 833 opt.jo_in_top = eap->line1;
831 opt.jo_in_bot = eap->line2; 834 opt.jo_in_bot = eap->line2;
832 } 835 }
833 836
834 argvar[0].v_type = VAR_STRING; 837 if (opt_shell && tofree == NULL)
835 argvar[0].vval.v_string = cmd; 838 {
836 argvar[1].v_type = VAR_UNKNOWN; 839 #ifdef UNIX
837 term_start(argvar, NULL, &opt, eap->forceit ? TERM_START_FORCEIT : 0); 840 char **argv = NULL;
841 char_u *tofree1 = NULL;
842 char_u *tofree2 = NULL;
843
844 // :term ++shell command
845 if (unix_build_argv(cmd, &argv, &tofree1, &tofree2) == OK)
846 term_start(NULL, argv, &opt, eap->forceit ? TERM_START_FORCEIT : 0);
847 vim_free(tofree1);
848 vim_free(tofree2);
849 #else
850 emsg(_("E279: Sorry, ++shell is not supported on this system"));
851 #endif
852 }
853 else
854 {
855 argvar[0].v_type = VAR_STRING;
856 argvar[0].vval.v_string = cmd;
857 argvar[1].v_type = VAR_UNKNOWN;
858 term_start(argvar, NULL, &opt, eap->forceit ? TERM_START_FORCEIT : 0);
859 }
860
838 vim_free(tofree); 861 vim_free(tofree);
839 862
840 theend: 863 theend:
841 vim_free(opt.jo_eof_chars); 864 vim_free(opt.jo_eof_chars);
842 } 865 }
6472 */ 6495 */
6473 static int 6496 static int
6474 term_and_job_init( 6497 term_and_job_init(
6475 term_T *term, 6498 term_T *term,
6476 typval_T *argvar, 6499 typval_T *argvar,
6477 char **argv UNUSED, 6500 char **argv,
6478 jobopt_T *opt, 6501 jobopt_T *opt,
6479 jobopt_T *orig_opt) 6502 jobopt_T *orig_opt)
6480 { 6503 {
6481 int use_winpty = FALSE; 6504 int use_winpty = FALSE;
6482 int use_conpty = FALSE; 6505 int use_conpty = FALSE;