From 3afcc6faac828be21da68576d196f5ab344f84d5 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 7 Oct 2020 08:23:55 +0000 Subject: [PATCH] Allow fnmatch(3) wildcards in update-environment, GitHub issue 2397. --- environ.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/environ.c b/environ.c index 940109b0..74d672e0 100644 --- a/environ.c +++ b/environ.c @@ -18,6 +18,7 @@ #include +#include #include #include #include @@ -191,7 +192,11 @@ 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); - if ((envent = environ_find(src, ov->string)) == NULL) + RB_FOREACH(envent, environ, src) { + if (fnmatch(ov->string, envent->name, 0) == 0) + break; + } + if (envent == NULL) environ_clear(dst, ov->string); else environ_set(dst, envent->name, 0, "%s", envent->value);