diff options
| author | Bram Moolenaar <Bram@vim.org> | 2017-08-11 19:12:11 +0200 |
|---|---|---|
| committer | Bram Moolenaar <Bram@vim.org> | 2017-08-11 19:12:11 +0200 |
| commit | 05aafed54b50b602315ae55d83a7d089804cecb0 (patch) | |
| tree | 5ba15103a30540de184b50ca8d82a7adaa2efd4d /src/os_unix.c | |
| parent | 76ca1b4041db71df899a40d2ab1701af4f19cb2a (diff) | |
| download | vim-git-05aafed54b50b602315ae55d83a7d089804cecb0.tar.gz | |
patch 8.0.0902: cannot specify directory or environment for a jobv8.0.0902
Problem: Cannot specify directory or environment for a job.
Solution: Add the "cwd" and "env" arguments to job options. (Yasuhiro
Matsumoto, closes #1160)
Diffstat (limited to 'src/os_unix.c')
| -rw-r--r-- | src/os_unix.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 141a3f010..c56de66db 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -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); |
