aboutsummaryrefslogtreecommitdiff
path: root/environ.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2019-03-18 15:07:51 +0000
committerThomas Adam <thomas@xteddy.org>2019-03-18 15:07:51 +0000
commitacb2413852b98745b69459d0cdd0d9698cb75e2c (patch)
tree6af803240715b8a6bccc328d5eda14f237e44944 /environ.c
parentaa2b3472c515dd1e5f57618e17c0c612cfa3c117 (diff)
parentce6be7afd4d10b542f9cce8634d6bdd81754f775 (diff)
downloadrtmux-acb2413852b98745b69459d0cdd0d9698cb75e2c.tar.gz
rtmux-acb2413852b98745b69459d0cdd0d9698cb75e2c.tar.bz2
rtmux-acb2413852b98745b69459d0cdd0d9698cb75e2c.zip
Merge branch 'obsd-master'
Diffstat (limited to 'environ.c')
-rw-r--r--environ.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/environ.c b/environ.c
index 29191ee5..2764e027 100644
--- a/environ.c
+++ b/environ.c
@@ -174,22 +174,26 @@ environ_unset(struct environ *env, const char *name)
void
environ_update(struct options *oo, struct environ *src, struct environ *dst)
{
- struct environ_entry *envent;
- struct options_entry *o;
- u_int size, idx;
- const char *value;
+ struct environ_entry *envent;
+ struct options_entry *o;
+ struct options_array_item *a;
+ const char *value;
o = options_get(oo, "update-environment");
- if (o == NULL || options_array_size(o, &size) == -1)
+ if (o == NULL)
return;
- for (idx = 0; idx < size; idx++) {
- value = options_array_get(o, idx);
- if (value == NULL)
+ a = options_array_first(o);
+ while (a != NULL) {
+ value = options_array_item_value(a);
+ if (value == NULL) {
+ a = options_array_next(a);
continue;
+ }
if ((envent = environ_find(src, value)) == NULL)
environ_clear(dst, value);
else
environ_set(dst, envent->name, "%s", envent->value);
+ a = options_array_next(a);
}
}