aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2020-09-14 17:19:25 +0200
committerregnat <rg@regnat.ovh>2020-09-14 17:19:25 +0200
commit250f8a4bbae2aeafd3fa3e637b52fbbb59a7a8e0 (patch)
treeb45f60c62363cc4ddf44ddb2a53b3388ef55e3ba /src
parenta59e77d9e54e8e7bf0f3c3f40c22cd34b7a81225 (diff)
Escape `${` in strings when printing Nix expressions
Otherwise the result of the printing can't be parsed back correctly by Nix (because the unescaped `${` will be parsed as the begining of an anti-quotation). Fix #3989
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/eval.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index dab11ce45..d678231c6 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -87,6 +87,7 @@ static void printValue(std::ostream & str, std::set<const Value *> & active, con
else if (*i == '\n') str << "\\n";
else if (*i == '\r') str << "\\r";
else if (*i == '\t') str << "\\t";
+ else if (*i == '$' && *(i+1) == '{') str << "\\" << *i;
else str << *i;
str << "\"";
break;