diff options
author | Thomas Adam <thomas@xteddy.org> | 2017-01-24 22:01:13 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2017-01-24 22:01:13 +0000 |
commit | 418ab1a553f46996d3524bab5c81b2c66fa7efc6 (patch) | |
tree | b29b61f95da6d7732628cdfb6dcf5e23c2fede5e /environ.c | |
parent | f38a6bbd816533d01d14c8bbafbb51621e5e1326 (diff) | |
parent | ffc28a7765f4b560427404c9679966232655e67e (diff) | |
download | rtmux-418ab1a553f46996d3524bab5c81b2c66fa7efc6.tar.gz rtmux-418ab1a553f46996d3524bab5c81b2c66fa7efc6.tar.bz2 rtmux-418ab1a553f46996d3524bab5c81b2c66fa7efc6.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'environ.c')
-rw-r--r-- | environ.c | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -169,25 +169,27 @@ environ_unset(struct environ *env, const char *name) free(envent); } -/* - * Copy a space-separated list of variables from a destination into a source - * environment. - */ +/* Copy variables from a destination into a source * environment. */ void -environ_update(const char *vars, struct environ *srcenv, - struct environ *dstenv) +environ_update(struct options *oo, struct environ *src, struct environ *dst) { struct environ_entry *envent; - char *copyvars, *var, *next; + struct options_entry *o; + u_int size, idx; + const char *value; - copyvars = next = xstrdup(vars); - while ((var = strsep(&next, " ")) != NULL) { - if ((envent = environ_find(srcenv, var)) == NULL) - environ_clear(dstenv, var); + o = options_get(oo, "update-environment"); + if (o == NULL || options_array_size(o, &size) == -1) + return; + for (idx = 0; idx < size; idx++) { + value = options_array_get(o, idx); + if (value == NULL) + continue; + if ((envent = environ_find(src, value)) == NULL) + environ_clear(dst, value); else - environ_set(dstenv, envent->name, "%s", envent->value); + environ_set(dst, envent->name, "%s", envent->value); } - free(copyvars); } /* Push environment into the real environment - use after fork(). */ |