0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.0.0902: cannot specify directory or environment for a job

Problem:    Cannot specify directory or environment for a job.
Solution:   Add the "cwd" and "env" arguments to job options. (Yasuhiro
            Matsumoto, closes #1160)
This commit is contained in:
Bram Moolenaar
2017-08-11 19:12:11 +02:00
parent 76ca1b4041
commit 05aafed54b
9 changed files with 252 additions and 43 deletions

View File

@@ -5320,6 +5320,22 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
# endif
set_default_child_environment();
if (options->jo_env != NULL)
{
dict_T *dict = options->jo_env;
hashitem_T *hi;
int todo = (int)dict->dv_hashtab.ht_used;
for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
typval_T *item = &dict_lookup(hi)->di_tv;
vim_setenv((char_u*)hi->hi_key, get_tv_string(item));
--todo;
}
}
if (use_null_for_in || use_null_for_out || use_null_for_err)
null_fd = open("/dev/null", O_RDWR | O_EXTRA, 0);
@@ -5387,6 +5403,9 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
if (null_fd >= 0)
close(null_fd);
if (options->jo_cwd != NULL && mch_chdir((char *)options->jo_cwd) != 0)
_exit(EXEC_FAILED);
/* See above for type of argv. */
execvp(argv[0], argv);