diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2022-08-15 08:37:04 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2022-08-15 08:37:04 +0000 |
commit | f4ab265f13a9bcbcaff0269aa01278a970064eae (patch) | |
tree | 0ad92856f9c80b49f6aea3ed129ae74860284dcb /usr.bin/tmux/environ.c | |
parent | 1ab0837bd133d2ef84edcdcb6d494373fd2f0c5c (diff) |
Don't stop at first match when updating environment.
Diffstat (limited to 'usr.bin/tmux/environ.c')
-rw-r--r-- | usr.bin/tmux/environ.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/usr.bin/tmux/environ.c b/usr.bin/tmux/environ.c index 36f5a821fbb..f1a9be3c742 100644 --- a/usr.bin/tmux/environ.c +++ b/usr.bin/tmux/environ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: environ.c,v 1.26 2020/10/07 08:23:55 nicm Exp $ */ +/* $OpenBSD: environ.c,v 1.27 2022/08/15 08:37:03 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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); } } |