mirror of
https://github.com/NixOS/nix
synced 2025-06-29 23:13:14 +02:00
Fix decoding virtual paths that are at the root of the tree
This commit is contained in:
parent
b27cd882ac
commit
515b908690
2 changed files with 4 additions and 3 deletions
|
@ -40,9 +40,8 @@ SourcePath EvalState::decodePath(std::string_view s, PosIdx pos)
|
|||
|
||||
try {
|
||||
auto slash = s.find('/');
|
||||
if (slash == std::string::npos) fail();
|
||||
size_t number = std::stoi(std::string(s, 0, slash), nullptr, 16);
|
||||
s = s.substr(slash);
|
||||
size_t number = std::stoi(std::string(s.substr(0, slash)), nullptr, 16);
|
||||
s = slash == s.npos ? "" : s.substr(slash);
|
||||
|
||||
auto accessor = inputAccessors.find(number);
|
||||
if (accessor == inputAccessors.end()) fail();
|
||||
|
|
|
@ -4,3 +4,5 @@ mkdir -p $TEST_ROOT/foo
|
|||
echo bla > $TEST_ROOT/foo/bar
|
||||
|
||||
[[ $(nix eval --raw --impure --expr "builtins.readFile (builtins.toString (builtins.fetchTree { type = \"path\"; path = \"$TEST_ROOT/foo\"; } + \"bar\"))") = bla ]]
|
||||
|
||||
[[ $(nix eval --json --impure --expr "builtins.readDir (builtins.toString (builtins.fetchTree { type = \"path\"; path = \"$TEST_ROOT/foo\"; }))") = '{"bar":"regular"}' ]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue