cache directory location is determined.
+=== Configuration value syntax
+
+All configuration values support expansion of environment variables. The syntax
+is similar to POSIX shell syntax: `$VAR` or `${VAR}`. Both variants will expand
+to the value of the environment variable `VAR`.
+
+Two consecutive dollar signs (`$$`) will expand to a single dollar sign (`$`).
+
+
=== Configuration file syntax
Configuration files are in a simple "`key = value`" format, one option per
max_size = 10G
-------------------------------------------------------------------------------
-
=== Boolean values
Some configuration options are boolean values (i.e. truth values). In a
std::string result;
const char* left = str.c_str();
const char* right = left;
+
while (*right) {
if (*right == '$') {
result.append(left, right - left);
+ if (*(right + 1) == '$') {
+ result += '$';
+ right += 2;
+ left = right;
+ continue;
+ }
+
left = right + 1;
bool curly = *left == '{';
if (curly) {
}
++right;
}
+
result += left;
return result;
}
CHECK(Util::expand_environment_variables("") == "");
CHECK(Util::expand_environment_variables("$FOO") == "bar");
- CHECK(Util::expand_environment_variables("$") == "$");
+ CHECK(Util::expand_environment_variables("$$FOO") == "$FOO");
+ CHECK(Util::expand_environment_variables("$$$FOO") == "$bar");
+ CHECK(Util::expand_environment_variables("$ $$ $") == "$ $ $");
CHECK(Util::expand_environment_variables("$FOO $FOO:$FOO") == "bar bar:bar");
CHECK(Util::expand_environment_variables("x$FOO") == "xbar");
CHECK(Util::expand_environment_variables("${FOO}x") == "barx");