mirror of
https://github.com/troglobit/finit.git
synced 2026-11-09 16:21:24 +00: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:
1 parent
50e587f447
commit
68f44f7a97
1 file changed
+14
-1
+14
-1
@@ -413,6 +413,7 @@ static void source_env(svc_t *svc)
|
|||||||
len = sizeof(buf);
|
len = sizeof(buf);
|
||||||
while (fgets(line, len, fp)) {
|
while (fgets(line, len, fp)) {
|
||||||
char *key = chomp(line);
|
char *key = chomp(line);
|
||||||
|
wordexp_t we = { 0 };
|
||||||
char *value, *end;
|
char *value, *end;
|
||||||
|
|
||||||
/* skip any leading whitespace */
|
/* skip any leading whitespace */
|
||||||
@@ -466,7 +467,19 @@ static void source_env(svc_t *svc)
|
|||||||
*end-- = 0;
|
*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);
|
fclose(fp);
|
||||||
|
|||||||
Reference in new issue
Block a user