From 20eb5466c0d34d76169eed3483cd744ecc2b6bea Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 20 Jan 2025 10:47:47 +0100 Subject: [PATCH] mv: show prompt for -u --interactive --- src/uu/mv/src/mv.rs | 7 ------- tests/by-util/test_mv.rs | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 675982bac..6e533dace 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -576,13 +576,6 @@ fn rename( let mut backup_path = None; if to.exists() { - if opts.update == UpdateMode::ReplaceIfOlder && opts.overwrite == OverwriteMode::Interactive - { - // `mv -i --update old new` when `new` exists doesn't move anything - // and exit with 0 - return Ok(()); - } - if opts.update == UpdateMode::ReplaceNone { if opts.debug { println!("skipped {}", to.quote()); diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index 1419be4e9..6441357f1 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -1119,6 +1119,30 @@ fn test_mv_arg_update_older_dest_older() { assert_eq!(at.read(old), new_content); } +#[test] +fn test_mv_arg_update_older_dest_older_interactive() { + let (at, mut ucmd) = at_and_ucmd!(); + + let old = "old"; + let new = "new"; + let old_content = "file1 content\n"; + let new_content = "file2 content\n"; + + let mut f = at.make_file(old); + f.write_all(old_content.as_bytes()).unwrap(); + f.set_modified(std::time::UNIX_EPOCH).unwrap(); + + at.write(new, new_content); + + ucmd.arg(new) + .arg(old) + .arg("--interactive") + .arg("--update=older") + .fails() + .stderr_contains("overwrite 'old'?") + .no_stdout(); +} + #[test] fn test_mv_arg_update_short_overwrite() { // same as --update=older