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/channel.c b/src/channel.c
index 7eb6ce7..3126cbd 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -4153,6 +4153,8 @@
partial_unref(opt->jo_exit_partial);
else if (opt->jo_exit_cb != NULL)
func_unref(opt->jo_exit_cb);
+ if (opt->jo_env != NULL)
+ dict_unref(opt->jo_env);
}
/*
@@ -4433,6 +4435,26 @@
opt->jo_term_finish = *val;
}
#endif
+ else if (STRCMP(hi->hi_key, "env") == 0)
+ {
+ if (!(supported & JO2_ENV))
+ break;
+ opt->jo_set |= JO2_ENV;
+ opt->jo_env = item->vval.v_dict;
+ ++item->vval.v_dict->dv_refcount;
+ }
+ else if (STRCMP(hi->hi_key, "cwd") == 0)
+ {
+ if (!(supported & JO2_CWD))
+ break;
+ opt->jo_cwd = get_tv_string_buf_chk(item, opt->jo_cwd_buf);
+ if (opt->jo_cwd == NULL || !mch_isdir(opt->jo_cwd))
+ {
+ EMSG2(_(e_invarg2), "cwd");
+ return FAIL;
+ }
+ opt->jo_set |= JO2_CWD;
+ }
else if (STRCMP(hi->hi_key, "waittime") == 0)
{
if (!(supported & JO_WAITTIME))