Fix cp -u/mv -u when the dst doesn't exist (#9662)

Fixes #9655
This commit is contained in:
mengsuenyan
2023-07-13 00:12:59 +08:00
committed by GitHub
parent 7c9edbd9ee
commit 026335fff0
5 changed files with 18 additions and 7 deletions

View File

@ -607,5 +607,9 @@ fn copy_file_with_update_flag_impl(progress: bool) {
sandbox.with_files(vec![FileWithContent("newest_valid.txt", "newest_body")]);
let actual = nu!(cwd: sandbox.cwd(), "cp {} -u newest_valid.txt valid.txt; open valid.txt", progress_flag);
assert_eq!(actual.out, "newest_body");
// when destination doesn't exist
let actual = nu!(cwd: sandbox.cwd(), "cp {} -u newest_valid.txt des_missing.txt; open des_missing.txt", progress_flag);
assert_eq!(actual.out, "newest_body");
});
}

View File

@ -484,5 +484,10 @@ fn mv_with_update_flag() {
sandbox.with_files(vec![FileWithContent("newest_valid.txt", "newest_body")]);
let actual = nu!(cwd: sandbox.cwd(), "mv -uf newest_valid.txt valid.txt; open valid.txt");
assert_eq!(actual.out, "newest_body");
// when destination doesn't exist
sandbox.with_files(vec![FileWithContent("newest_valid.txt", "newest_body")]);
let actual = nu!(cwd: sandbox.cwd(), "mv -uf newest_valid.txt des_missing.txt; open des_missing.txt");
assert_eq!(actual.out, "newest_body");
});
}