diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-07-08 04:09:59 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-07-08 04:09:59 +0200 |
commit | fab56fc541cebdbbc4cc273c3f0807eb7807b9fd (patch) | |
tree | b0c6a377c3e087000ac66ce57515571ef94f779c /src/strv.c | |
parent | 1e3ad081efda42dd1cc737ce7e98be8889c78340 (diff) |
execute: support minimal environment variable replacement when executing processes
Diffstat (limited to 'src/strv.c')
-rw-r--r-- | src/strv.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/strv.c b/src/strv.c index a66369602b..9dbab2937c 100644 --- a/src/strv.c +++ b/src/strv.c @@ -539,3 +539,20 @@ fail: return NULL; } + +char *strv_env_get_with_length(char **l, const char *name, size_t k) { + char **i; + + assert(name); + + STRV_FOREACH(i, l) + if (strncmp(*i, name, k) == 0 && + (*i)[k] == '=') + return *i + k + 1; + + return NULL; +} + +char *strv_env_get(char **l, const char *name) { + return strv_env_get_with_length(l, name, strlen(name)); +} |