diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 90ef8500d..b85f3c8d8 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1828,6 +1828,13 @@ fn handle_existing_dest( return Err(format!("{} and {} are the same file", source.quote(), dest.quote()).into()); } + if options.update == UpdateMode::ReplaceNone { + if options.debug { + println!("skipped {}", dest.quote()); + } + return Err(Error::Skipped(false)); + } + if options.update != UpdateMode::ReplaceIfOlder { options.overwrite.verify(dest, options.debug)?; } diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 2b8404283..9a24792b0 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -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"); +}