mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #7178 from cakebaker/mv_make_update_sh_pass
mv: show prompt for `-u --interactive`
This commit is contained in:
commit
d92d756d0d
2 changed files with 24 additions and 7 deletions
|
@ -576,13 +576,6 @@ fn rename(
|
||||||
let mut backup_path = None;
|
let mut backup_path = None;
|
||||||
|
|
||||||
if to.exists() {
|
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.update == UpdateMode::ReplaceNone {
|
||||||
if opts.debug {
|
if opts.debug {
|
||||||
println!("skipped {}", to.quote());
|
println!("skipped {}", to.quote());
|
||||||
|
|
|
@ -1119,6 +1119,30 @@ fn test_mv_arg_update_older_dest_older() {
|
||||||
assert_eq!(at.read(old), new_content);
|
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]
|
#[test]
|
||||||
fn test_mv_arg_update_short_overwrite() {
|
fn test_mv_arg_update_short_overwrite() {
|
||||||
// same as --update=older
|
// same as --update=older
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue