mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
cp: fix update prompting (#7668)
* added logic to check if we are updating the file and the destination is newer, to skip copying * corrected logic to handle cp update * - added test case that mocks the issue described in #7660 - adjusted conditions to satisfy clippy * typo * Update src/uu/cp/src/cp.rs Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com> * Update tests/by-util/test_cp.rs Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com> --------- Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
This commit is contained in:
parent
45c978fae6
commit
cd2b56ea9c
2 changed files with 24 additions and 0 deletions
|
@ -6167,3 +6167,20 @@ fn test_cp_update_older_interactive_prompt_no() {
|
|||
.fails()
|
||||
.stdout_is("cp: overwrite 'old'? ");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cp_update_none_interactive_prompt_no() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let old_file = "old";
|
||||
let new_file = "new";
|
||||
|
||||
at.write(old_file, "old content");
|
||||
at.write(new_file, "new content");
|
||||
|
||||
ucmd.args(&["-i", "--update=none", new_file, old_file])
|
||||
.succeeds()
|
||||
.no_output();
|
||||
|
||||
assert_eq!(at.read(old_file), "old content");
|
||||
assert_eq!(at.read(new_file), "new content");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue