diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-01-06 20:38:02 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-01-06 20:38:02 +0100 |
commit | a6ff950e71ea665fff99740f7b3e0137d451a79e (patch) | |
tree | 502ff29d4c0d410285e54666571b1831061e6af0 /src/strv.c | |
parent | 7fc942b29e7bdb9d6aa3123f53da6680edabd8f0 (diff) |
execute: drop empty assignments from env blocks on execution but keep them around otherwise to make them visible
Diffstat (limited to 'src/strv.c')
-rw-r--r-- | src/strv.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/strv.c b/src/strv.c index d9aef98224..d1c7b2c32d 100644 --- a/src/strv.c +++ b/src/strv.c @@ -380,7 +380,7 @@ static int env_append(char **r, char ***k, char **a) { /* Add the entries of a to *k unless they already exist in *r * in which case they are overriden instead. This assumes - * there is enough space in the r */ + * there is enough space in the r array. */ for (; *a; a++) { char **j; @@ -556,3 +556,24 @@ char *strv_env_get_with_length(char **l, const char *name, size_t k) { char *strv_env_get(char **l, const char *name) { return strv_env_get_with_length(l, name, strlen(name)); } + +char **strv_env_clean(char **l) { + char **r, **ret; + + for (r = ret = l; *l; l++) { + const char *equal; + + equal = strchr(*l, '='); + + if (equal && equal[1] == 0) { + free(*l); + continue; + } + + *(r++) = *l; + } + + *r = NULL; + + return ret; +} |