diff options
author | Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com> | 2022-06-24 10:02:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-24 10:02:40 +0200 |
commit | f06b6fa4faa3283c28a01579d89ee4039d7ecc36 (patch) | |
tree | c3b8f07f32728335114db462d34347d55104384a | |
parent | 2ef6785d8e0c87d8b0cacbe2449683d9fd2e5844 (diff) | |
parent | 983efdbde47bd0ecaff866d43c3155761574c112 (diff) |
Merge pull request #6698 from tweag/forbid-tilde-paths-in-pure-mode
Forbid the tilde expansion in pure eval mode
-rw-r--r-- | src/libexpr/parser.y | 6 | ||||
-rw-r--r-- | tests/pure-eval.sh | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 8cbc2da4d..7c9b5a2db 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -520,6 +520,12 @@ path_start $$ = new ExprPath(path); } | HPATH { + if (evalSettings.pureEval) { + throw Error( + "the path '%s' can not be resolved in pure mode", + std::string_view($1.p, $1.l) + ); + } Path path(getHome() + std::string($1.p + 1, $1.l - 1)); $$ = new ExprPath(path); } diff --git a/tests/pure-eval.sh b/tests/pure-eval.sh index 1a4568ea6..b83ab8afe 100644 --- a/tests/pure-eval.sh +++ b/tests/pure-eval.sh @@ -30,3 +30,5 @@ nix eval --store dummy:// --write-to $TEST_ROOT/eval-out --expr '{ x = "foo" + " rm -rf $TEST_ROOT/eval-out (! nix eval --store dummy:// --write-to $TEST_ROOT/eval-out --expr '{ "." = "bla"; }') + +(! nix eval --expr '~/foo') |