mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
mv: Show 'skipped' when a file isn't overwriten
Should fix tests/mv/mv-n.sh
This commit is contained in:
parent
e920d8d1bd
commit
d38797bb50
2 changed files with 33 additions and 4 deletions
|
@ -440,13 +440,19 @@ fn rename(
|
||||||
|
|
||||||
match b.overwrite {
|
match b.overwrite {
|
||||||
OverwriteMode::NoClobber => {
|
OverwriteMode::NoClobber => {
|
||||||
return Err(io::Error::new(
|
let err_msg = if b.verbose {
|
||||||
io::ErrorKind::Other,
|
println!("skipped {}", to.quote());
|
||||||
format!("not replacing {}", to.quote()),
|
String::new()
|
||||||
));
|
} else {
|
||||||
|
format!("not replacing {}", to.quote())
|
||||||
|
};
|
||||||
|
return Err(io::Error::new(io::ErrorKind::Other, err_msg));
|
||||||
}
|
}
|
||||||
OverwriteMode::Interactive => {
|
OverwriteMode::Interactive => {
|
||||||
if !prompt_yes!("overwrite {}?", to.quote()) {
|
if !prompt_yes!("overwrite {}?", to.quote()) {
|
||||||
|
if b.verbose {
|
||||||
|
println!("skipped {}", to.quote());
|
||||||
|
}
|
||||||
return Err(io::Error::new(io::ErrorKind::Other, ""));
|
return Err(io::Error::new(io::ErrorKind::Other, ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1243,6 +1243,29 @@ fn test_mv_info_self() {
|
||||||
.stderr_contains("mv: cannot move 'dir2' to a subdirectory of itself, 'dir2/dir2'");
|
.stderr_contains("mv: cannot move 'dir2' to a subdirectory of itself, 'dir2/dir2'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_mv_arg_interactive_skipped() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
at.touch("a");
|
||||||
|
at.touch("b");
|
||||||
|
ucmd.args(&["-vi", "a", "b"])
|
||||||
|
.pipe_in("N\n")
|
||||||
|
.ignore_stdin_write_error()
|
||||||
|
.fails()
|
||||||
|
.stderr_is("mv: overwrite 'b'? ")
|
||||||
|
.stdout_is("skipped 'b'\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_mv_arg_interactive_skipped_vin() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
at.touch("a");
|
||||||
|
at.touch("b");
|
||||||
|
ucmd.args(&["-vin", "a", "b"])
|
||||||
|
.fails()
|
||||||
|
.stdout_is("skipped 'b'\n");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mv_into_self_data() {
|
fn test_mv_into_self_data() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue