summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/env-util.c15
-rw-r--r--src/shared/env-util.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/src/shared/env-util.c b/src/shared/env-util.c
index 7a213a77c0..9a833d22e4 100644
--- a/src/shared/env-util.c
+++ b/src/shared/env-util.c
@@ -135,6 +135,21 @@ bool strv_env_is_valid(char **e) {
return true;
}
+bool strv_env_name_or_assignment_is_valid(char **l) {
+ char **p, **q;
+
+ STRV_FOREACH(p, l) {
+ if (!env_assignment_is_valid(*p) && !env_name_is_valid(*p))
+ return false;
+
+ STRV_FOREACH(q, p + 1)
+ if (streq(*p, *q))
+ return false;
+ }
+
+ return true;
+}
+
static int env_append(char **r, char ***k, char **a) {
assert(r);
assert(k);
diff --git a/src/shared/env-util.h b/src/shared/env-util.h
index 93bf596ca8..9449576b5c 100644
--- a/src/shared/env-util.h
+++ b/src/shared/env-util.h
@@ -31,6 +31,8 @@ bool env_assignment_is_valid(const char *e);
bool strv_env_is_valid(char **e);
char **strv_env_clean(char **l);
+bool strv_env_name_or_assignment_is_valid(char **l);
+
char **strv_env_merge(unsigned n_lists, ...);
char **strv_env_delete(char **x, unsigned n_lists, ...); /* New copy */