1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +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:
Ashe Leclerc 2022-04-10 06:14:01 +02:00 committed by Sylvestre Ledru
parent f114d63b4e
commit 1d76c96570

View file

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