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)
diff --git a/src/os_unix.c b/src/os_unix.c
index 141a3f0..c56de66 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5320,6 +5320,22 @@
# 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 @@
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);