mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
mv: make sure it continues when hiting an error
This commit is contained in:
parent
9c7fd5e8cb
commit
c94773f522
2 changed files with 28 additions and 1 deletions
|
@ -478,7 +478,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, options: &Options)
|
|||
if moved_destinations.contains(&targetpath) && options.backup != BackupMode::NumberedBackup
|
||||
{
|
||||
// If the target file was already created in this mv call, do not overwrite
|
||||
return Err(USimpleError::new(
|
||||
show!(USimpleError::new(
|
||||
1,
|
||||
format!(
|
||||
"will not overwrite just-created '{}' with '{}'",
|
||||
|
@ -486,6 +486,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, options: &Options)
|
|||
sourcepath.display()
|
||||
),
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if we have mv dir1 dir2 dir2
|
||||
|
|
|
@ -1495,6 +1495,32 @@ fn test_mv_seen_file() {
|
|||
assert!(!at.plus("a").join("f").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_seen_multiple_files_to_directory() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
|
||||
at.mkdir("a");
|
||||
at.mkdir("b");
|
||||
at.mkdir("c");
|
||||
at.write("a/f", "a");
|
||||
at.write("b/f", "b");
|
||||
at.write("b/g", "g");
|
||||
|
||||
ts.ucmd()
|
||||
.arg("a/f")
|
||||
.arg("b/f")
|
||||
.arg("b/g")
|
||||
.arg("c")
|
||||
.fails()
|
||||
.stderr_contains("will not overwrite just-created 'c/f' with 'b/f'");
|
||||
assert!(!at.plus("a").join("f").exists());
|
||||
assert!(at.plus("b").join("f").exists());
|
||||
assert!(!at.plus("b").join("g").exists());
|
||||
assert!(at.plus("c").join("f").exists());
|
||||
assert!(at.plus("c").join("g").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_dir_into_file_where_both_are_files() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue