File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -359,11 +359,18 @@ string_parts_interpolated
359359
360360path_start
361361 : PATH {
362- Path path(absPath(std::string_view{$1.p, $1.l}, state->basePath.path.abs()));
362+ std ::string_view literal ({$1 .p, $1 .l});
363+ Path path(absPath(literal, state->basePath.path.abs()));
363364 /* add back in the trailing '/' to the first segment */
364- if ($1.p[$1.l-1] == '/' && $1.l > 1)
365- path += "/";
366- $$ = new ExprPath(ref<SourceAccessor>(state->rootFS), std::move(path));
365+ if (literal.size() > 1 && literal.back() == '/')
366+ path += '/';
367+ $$ =
368+ /* Absolute paths are always interpreted relative to the
369+ root filesystem accessor, rather than the accessor of the
370+ current Nix expression. */
371+ literal.front() == '/'
372+ ? new ExprPath(state->rootFS, std::move(path))
373+ : new ExprPath(state->basePath.accessor, std::move(path));
367374 }
368375 | HPATH {
369376 if (state->settings.pureEval) {
You can’t perform that action at this time.
0 commit comments