mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
Fix #377: expand service env:file variables
This change allows us to support constructs like this:
RUNDIR=/var/run/somesvc
DAEMON_ARGS=--workdir $RUNDIR --other-args...
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+14
-1
@@ -413,6 +413,7 @@ static void source_env(svc_t *svc)
|
||||
len = sizeof(buf);
|
||||
while (fgets(line, len, fp)) {
|
||||
char *key = chomp(line);
|
||||
wordexp_t we = { 0 };
|
||||
char *value, *end;
|
||||
|
||||
/* skip any leading whitespace */
|
||||
@@ -466,7 +467,19 @@ static void source_env(svc_t *svc)
|
||||
*end-- = 0;
|
||||
}
|
||||
|
||||
setenv(key, value, 1);
|
||||
switch (wordexp(value, &we, 0)) {
|
||||
case 0:
|
||||
setenv(key, we.we_wordv[0], 1);
|
||||
wordfree(&we);
|
||||
break;
|
||||
|
||||
case WRDE_NOSPACE:
|
||||
wordfree(&we);
|
||||
/* fallthrough */
|
||||
default:
|
||||
setenv(key, value, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
Reference in New Issue
Block a user