Allow braceless variables to be expanded

(Only in environment.d files.)

We have only basic compatibility with shell syntax, but specifying variables
without using braces is probably more common, and I think a lot of people would
be surprised if this didn't work.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2017-02-20 23:30:50 -05:00
parent cb4499d005
commit ccad1fd07c
6 changed files with 91 additions and 11 deletions
+6 -1
View File
@@ -773,7 +773,8 @@ static int merge_env_file_push(
assert(env);
expanded_value = replace_env(value, *env, REPLACE_ENV_USE_ENVIRONMENT);
expanded_value = replace_env(value, *env,
REPLACE_ENV_USE_ENVIRONMENT|REPLACE_ENV_ALLOW_BRACELESS);
if (!expanded_value)
return -ENOMEM;
@@ -787,6 +788,10 @@ int merge_env_file(
FILE *f,
const char *fname) {
/* NOTE: this function supports braceful and braceless variable expansions,
* unlike other exported parsing functions.
*/
return parse_env_file_internal(f, fname, NEWLINE, merge_env_file_push, env, NULL);
}