diff options
author | nicm <nicm> | 2020-10-07 08:23:55 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-10-07 08:23:55 +0000 |
commit | 3afcc6faac828be21da68576d196f5ab344f84d5 (patch) | |
tree | 2610b6563a445024a2f5bd4b5eb8427e3e3c52e9 /environ.c | |
parent | 7e319756d2450798855c648ede9fbcf7beb187e2 (diff) |
Allow fnmatch(3) wildcards in update-environment, GitHub issue 2397.
Diffstat (limited to 'environ.c')
-rw-r--r-- | environ.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -18,6 +18,7 @@ #include <sys/types.h> +#include <fnmatch.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -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); |