]> granicus.if.org Git - vim/commitdiff
patch 8.0.1240: MS-Windows: term_start() does not support environment v8.0.1240
authorBram Moolenaar <Bram@vim.org>
Mon, 30 Oct 2017 20:56:23 +0000 (21:56 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 30 Oct 2017 20:56:23 +0000 (21:56 +0100)
Problem:    MS-Windows: term_start() does not support environment.
Solution:   Implement the environment argument. (Yasuhiro Matsumoto, closes
            #2264)

src/os_win32.c
src/proto/os_win32.pro
src/terminal.c
src/testdir/test_terminal.vim
src/version.c

index f1e1cad8e3ca9f7ca372cf6d5349e4268c5cb3b4..7654c310020bbcf7ede2e5c974388aada861c7f7 100644 (file)
@@ -5033,8 +5033,8 @@ job_io_file_open(
  * Turn the dictionary "env" into a NUL separated list that can be used as the
  * environment argument of vim_create_process().
  */
-    static void
-make_job_env(garray_T *gap, dict_T *env)
+    void
+win32_build_env(dict_T *env, garray_T *gap)
 {
     hashitem_T *hi;
     int                todo = (int)env->dv_hashtab.ht_used;
@@ -5133,7 +5133,7 @@ mch_job_start(char *cmd, job_T *job, jobopt_T *options)
     }
 
     if (options->jo_env != NULL)
-       make_job_env(&ga, options->jo_env);
+       win32_build_env(options->jo_env, &ga);
 
     ZeroMemory(&pi, sizeof(pi));
     ZeroMemory(&si, sizeof(si));
index 7e6953c7da89c6bbaa5c41586e29f12370a995df..188a45be064e8d464380256242fc0f129fca0484 100644 (file)
@@ -67,4 +67,5 @@ void used_file_arg(char *name, int literal, int full_path, int diff_mode);
 void set_alist_count(void);
 void fix_arg_enc(void);
 int mch_setenv(char *var, char *value, int x);
+void win32_build_env(dict_T *l, garray_T *gap);
 /* vim: set ft=c : */
index efd803c6fb8c8b78f183093930cd7f2586d82b16..25c7d66cb9de8ef7dd5cf04c11926aaae63571de 100644 (file)
  * - Redirecting output does not work on MS-Windows, Test_terminal_redir_file()
  *   is disabled.
  * - cursor blinks in terminal on widows with a timer. (xtal8, #2142)
+ * - When closing gvim with an active terminal buffer, the dialog suggests
+ *   saving the buffer.  Should say something else. (Manas Thakur, #2215)
+ *   Also: #2223
  * - implement term_setsize()
+ * - Termdebug does not work when Vim build with mzscheme.  gdb hangs.
+ * - Termdebug: issue #2154 might be avoided by adding -quiet to gdb?
+ *   patch by Christian, 2017 Oct 23.
  * - MS-Windows GUI: WinBar has  tearoff item
  * - MS-Windows GUI: still need to type a key after shell exits?  #1924
+ * - What to store in a session file?  Shell at the prompt would be OK to
+ *   restore, but others may not.  Open the window and let the user start the
+ *   command?
  * - add test for giving error for invalid 'termsize' value.
  * - support minimal size when 'termsize' is "rows*cols".
  * - support minimal size when 'termsize' is empty?
@@ -3390,6 +3399,7 @@ term_and_job_init(
 {
     WCHAR          *cmd_wchar = NULL;
     WCHAR          *cwd_wchar = NULL;
+    WCHAR          *env_wchar = NULL;
     channel_T      *channel = NULL;
     job_T          *job = NULL;
     DWORD          error;
@@ -3398,7 +3408,7 @@ term_and_job_init(
     HANDLE         child_thread_handle;
     void           *winpty_err;
     void           *spawn_config = NULL;
-    garray_T       ga;
+    garray_T       ga_cmd, ga_env;
     char_u         *cmd;
 
     if (dyn_winpty_init(TRUE) == FAIL)
@@ -3408,10 +3418,10 @@ term_and_job_init(
        cmd = argvar->vval.v_string;
     else
     {
-       ga_init2(&ga, (int)sizeof(char*), 20);
-       if (win32_build_cmd(argvar->vval.v_list, &ga) == FAIL)
+       ga_init2(&ga_cmd, (int)sizeof(char*), 20);
+       if (win32_build_cmd(argvar->vval.v_list, &ga_cmd) == FAIL)
            goto failed;
-       cmd = ga.ga_data;
+       cmd = ga_cmd.ga_data;
     }
 
     cmd_wchar = enc_to_utf16(cmd, NULL);
@@ -3419,6 +3429,12 @@ term_and_job_init(
        return FAIL;
     if (opt->jo_cwd != NULL)
        cwd_wchar = enc_to_utf16(opt->jo_cwd, NULL);
+    if (opt->jo_env != NULL)
+    {
+       ga_init2(&ga_env, (int)sizeof(char*), 20);
+       win32_build_env(opt->jo_env, &ga_env);
+       env_wchar = ga_env.ga_data;
+    }
 
     job = job_alloc();
     if (job == NULL)
@@ -3446,7 +3462,7 @@ term_and_job_init(
            NULL,
            cmd_wchar,
            cwd_wchar,
-           NULL,
+           env_wchar,
            &winpty_err);
     if (spawn_config == NULL)
        goto failed;
@@ -3519,7 +3535,9 @@ term_and_job_init(
 
 failed:
     if (argvar->v_type == VAR_LIST)
-       vim_free(ga.ga_data);
+       vim_free(ga_cmd.ga_data);
+    if (opt->jo_env != NULL)
+       vim_free(ga_env.ga_data);
     vim_free(cmd_wchar);
     vim_free(cwd_wchar);
     if (spawn_config != NULL)
index bd7821d90d7078d6f9a2a012c6e76e0b189b3ff9..95c1b98e70257d79af78f9dde43007518f839889 100644 (file)
@@ -11,7 +11,11 @@ let s:python = PythonProg()
 " Open a terminal with a shell, assign the job to g:job and return the buffer
 " number.
 func Run_shell_in_terminal(options)
-  let buf = term_start(&shell, a:options)
+  if has('win32')
+    let buf = term_start([&shell,'/k'], a:options)
+  else
+    let buf = term_start(&shell, a:options)
+  endif
 
   let termlist = term_list()
   call assert_equal(1, len(termlist))
@@ -430,13 +434,14 @@ func Test_terminal_cwd()
 endfunc
 
 func Test_terminal_env()
-  if !has('unix')
-    return
-  endif
   let g:buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}})
   " Wait for the shell to display a prompt
   call WaitFor('term_getline(g:buf, 1) != ""')
-  call term_sendkeys(g:buf, "echo $TESTENV\r")
+  if has('win32')
+    call term_sendkeys(g:buf, "echo %TESTENV%\r")
+  else
+    call term_sendkeys(g:buf, "echo $TESTENV\r")
+  endif
   call term_wait(g:buf)
   call Stop_shell_in_terminal(g:buf)
   call WaitFor('getline(2) == "correct"')
index bb1e8b28d27a619c70509a2ba1a0b453bef39e48..339ff1d320964c1d815e3b0b3f50f29af23d1e7f 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1240,
 /**/
     1239,
 /**/