From 05aafed54b50b602315ae55d83a7d089804cecb0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 11 Aug 2017 19:12:11 +0200 Subject: 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) --- src/os_unix.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/os_unix.c') 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); -- cgit v1.2.1