mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +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:
parent
a97199f72a
commit
1c8aac0883
2 changed files with 22 additions and 1 deletions
|
@ -292,7 +292,7 @@ fn exec(files: &[OsString], b: &Behavior) -> UResult<()> {
|
||||||
OverwriteMode::NoClobber => return Ok(()),
|
OverwriteMode::NoClobber => return Ok(()),
|
||||||
OverwriteMode::Interactive => {
|
OverwriteMode::Interactive => {
|
||||||
if !prompt_yes!("overwrite {}? ", target.quote()) {
|
if !prompt_yes!("overwrite {}? ", target.quote()) {
|
||||||
return Ok(());
|
return Err(io::Error::new(io::ErrorKind::Other, "").into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OverwriteMode::Force => {}
|
OverwriteMode::Force => {}
|
||||||
|
|
|
@ -260,6 +260,27 @@ fn test_mv_interactive_with_dir_as_target() {
|
||||||
.no_stdout();
|
.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]
|
#[test]
|
||||||
fn test_mv_arg_update_interactive() {
|
fn test_mv_arg_update_interactive() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue