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

mv: if more than one of -i, -n, -f, latest "wins"

This commit is contained in:
Daniel Hofstetter 2023-05-05 10:11:40 +02:00
parent 4ee1118061
commit 93c8623da9
3 changed files with 40 additions and 0 deletions

View file

@ -280,6 +280,41 @@ fn test_mv_interactive_dir_to_file_not_affirmative() {
assert!(at.dir_exists(dir));
}
#[test]
fn test_mv_interactive_no_clobber_force_last_arg_wins() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let file_a = "a.txt";
let file_b = "b.txt";
at.touch(file_a);
at.touch(file_b);
scene
.ucmd()
.args(&[file_a, file_b, "-f", "-i", "-n"])
.fails()
.stderr_is(format!("mv: not replacing '{file_b}'\n"));
scene
.ucmd()
.args(&[file_a, file_b, "-n", "-f", "-i"])
.fails()
.stderr_is(format!("mv: overwrite '{file_b}'? "));
at.write(file_a, "aa");
scene
.ucmd()
.args(&[file_a, file_b, "-i", "-n", "-f"])
.succeeds()
.no_output();
assert!(!at.file_exists(file_a));
assert_eq!("aa", at.read(file_b));
}
#[test]
fn test_mv_arg_update_interactive() {
let (at, mut ucmd) = at_and_ucmd!();