=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/environ.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- src/usr.bin/tmux/environ.c 2020/10/07 08:23:55 1.26 +++ src/usr.bin/tmux/environ.c 2022/08/15 08:37:03 1.27 @@ -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 @@ -182,9 +182,11 @@ 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 @@ 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); } }