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

Merge pull request #7178 from cakebaker/mv_make_update_sh_pass

mv: show prompt for `-u --interactive`
This commit is contained in:
Sylvestre Ledru 2025-01-20 11:29:08 +01:00 committed by GitHub
commit d92d756d0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 7 deletions

View file

@ -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());

View file

@ -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