mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
mv: add OverwriteMode match in specific case
Check OverwriteMode and act depending on its value, specifically in the the case of overwriting a non-directory with a directory(#3337)
This commit is contained in:
parent
f114d63b4e
commit
1d76c96570
1 changed files with 10 additions and 0 deletions
|
@ -258,6 +258,16 @@ fn exec(files: &[OsString], b: &Behavior) -> UResult<()> {
|
|||
move_files_into_dir(&[source.clone()], target, b)
|
||||
}
|
||||
} else if target.exists() && source.is_dir() {
|
||||
match b.overwrite {
|
||||
OverwriteMode::NoClobber => return Ok(()),
|
||||
OverwriteMode::Interactive => {
|
||||
println!("{}: overwrite {}? ", uucore::util_name(), target.quote());
|
||||
if !read_yes() {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
OverwriteMode::Force => {}
|
||||
};
|
||||
Err(MvError::NonDirectoryToDirectory(
|
||||
source.quote().to_string(),
|
||||
target.quote().to_string(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue