1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

mv: return err if response is negative when moving a dir to existing dest during an interactive mode

This commit is contained in:
John Shin 2023-05-03 16:05:21 -07:00
parent a97199f72a
commit 1c8aac0883
2 changed files with 22 additions and 1 deletions

View file

@ -292,7 +292,7 @@ fn exec(files: &[OsString], b: &Behavior) -> UResult<()> {
OverwriteMode::NoClobber => return Ok(()),
OverwriteMode::Interactive => {
if !prompt_yes!("overwrite {}? ", target.quote()) {
return Ok(());
return Err(io::Error::new(io::ErrorKind::Other, "").into());
}
}
OverwriteMode::Force => {}

View file

@ -260,6 +260,27 @@ fn test_mv_interactive_with_dir_as_target() {
.no_stdout();
}
#[test]
fn test_mv_interactive_dir_to_file_not_affirmative() {
let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_mv_interactive_dir_to_file_not_affirmative_dir";
let file = "test_mv_interactive_dir_to_file_not_affirmative_file";
at.mkdir(dir);
at.touch(file);
ucmd.arg(dir)
.arg(file)
.arg("-i")
.pipe_in("n")
.fails()
.no_stderr()
.no_stdout();
assert!(at.dir_exists(dir));
}
#[test]
fn test_mv_arg_update_interactive() {
let (at, mut ucmd) = at_and_ucmd!();