Fix rm path handling (#11064)

# Description
Fixes issue #11061 where `rm` fails to find a file after a `cd`. It
looks like the new glob functions do not return absolute file paths
which we forgot to account for.

# Tests
Added a test (fails on current main, but passes with this PR).

---------

Co-authored-by: Jakub Žádník <kubouch@gmail.com>
This commit is contained in:
Ian Manske
2023-11-16 23:30:15 +00:00
committed by sholderbach
parent 77a1c3c7b2
commit b8e9293c45
2 changed files with 19 additions and 2 deletions

View File

@ -375,6 +375,21 @@ fn removes_symlink() {
});
}
#[test]
fn removes_file_after_cd() {
Playground::setup("rm_after_cd", |dirs, sandbox| {
sandbox.with_files(vec![EmptyFile("delete.txt")]);
nu!(
cwd: dirs.root(),
"let file = 'delete.txt'; cd rm_after_cd; rm $file",
);
let path = dirs.test().join("delete.txt");
assert!(!path.exists());
})
}
struct Cleanup<'a> {
dir_to_clean: &'a Path,
}