diff options
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/env-util.c | 15 | ||||
-rw-r--r-- | src/basic/env-util.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/basic/env-util.c b/src/basic/env-util.c index 9ddac5d6a1..441169db31 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -138,6 +138,21 @@ bool strv_env_is_valid(char **e) { return true; } +bool strv_env_name_is_valid(char **l) { + char **p, **q; + + STRV_FOREACH(p, l) { + if (!env_name_is_valid(*p)) + return false; + + STRV_FOREACH(q, p + 1) + if (streq(*p, *q)) + return false; + } + + return true; +} + bool strv_env_name_or_assignment_is_valid(char **l) { char **p, **q; diff --git a/src/basic/env-util.h b/src/basic/env-util.h index 6485dade18..5efffa3dc7 100644 --- a/src/basic/env-util.h +++ b/src/basic/env-util.h @@ -36,6 +36,7 @@ bool strv_env_is_valid(char **e); #define strv_env_clean(l) strv_env_clean_with_callback(l, NULL, NULL) char **strv_env_clean_with_callback(char **l, void (*invalid_callback)(const char *p, void *userdata), void *userdata); +bool strv_env_name_is_valid(char **l); bool strv_env_name_or_assignment_is_valid(char **l); char **strv_env_merge(unsigned n_lists, ...); |