Fix touch --reference using PWD from the environment (#12976)

This PR fixes `touch --reference path` so that it resolves `path` using
PWD from the engine state.
This commit is contained in:
YizhePKU
2024-05-27 01:24:00 +08:00
committed by GitHub
parent a1fc41db22
commit f74dd33ba9
2 changed files with 18 additions and 7 deletions

View File

@ -515,3 +515,16 @@ fn respects_cwd() {
assert!(path.exists());
})
}
#[test]
fn reference_respects_cwd() {
Playground::setup("touch_reference_respects_cwd", |dirs, _sandbox| {
nu!(
cwd: dirs.test(),
"mkdir 'dir'; cd 'dir'; touch 'ref.txt'; touch --reference 'ref.txt' 'foo.txt'"
);
let path = dirs.test().join("dir/foo.txt");
assert!(path.exists());
})
}