aboutsummaryrefslogtreecommitdiff
path: root/environ.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2022-08-15 13:54:47 +0100
committerThomas Adam <thomas@xteddy.org>2022-08-15 13:54:47 +0100
commit9c34aad21c0837123a51a5a4233a016805d3e526 (patch)
tree4c31065069418a60bb125e2d33e77c8993855d96 /environ.c
parent9b08e5139baf7cd61d096c128b6a794f6a634102 (diff)
parent7c2dcd72380dc2d9e119e99cb423a67ae17b6bd2 (diff)
downloadrtmux-9c34aad21c0837123a51a5a4233a016805d3e526.tar.gz
rtmux-9c34aad21c0837123a51a5a4233a016805d3e526.tar.bz2
rtmux-9c34aad21c0837123a51a5a4233a016805d3e526.zip
Merge branch 'obsd-master'
Diffstat (limited to 'environ.c')
-rw-r--r--environ.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/environ.c b/environ.c
index 74d672e0..5abf383c 100644
--- a/environ.c
+++ b/environ.c
@@ -182,9 +182,11 @@ void
environ_update(struct options *oo, struct environ *src, struct environ *dst)
{
struct environ_entry *envent;
+ struct environ_entry *envent1;
struct options_entry *o;
struct options_array_item *a;
union options_value *ov;
+ int found;
o = options_get(oo, "update-environment");
if (o == NULL)
@@ -192,14 +194,15 @@ environ_update(struct options *oo, struct environ *src, struct environ *dst)
a = options_array_first(o);
while (a != NULL) {
ov = options_array_item_value(a);
- RB_FOREACH(envent, environ, src) {
- if (fnmatch(ov->string, envent->name, 0) == 0)
- break;
+ found = 0;
+ RB_FOREACH_SAFE(envent, environ, src, envent1) {
+ if (fnmatch(ov->string, envent->name, 0) == 0) {
+ environ_set(dst, envent->name, 0, "%s", envent->value);
+ found = 1;
+ }
}
- if (envent == NULL)
+ if (!found)
environ_clear(dst, ov->string);
- else
- environ_set(dst, envent->name, 0, "%s", envent->value);
a = options_array_next(a);
}
}