forked from extern/nushell
Return error when moving a source directory to a target directory which contains a subdirectory with the same name as the source (#6284)
Fixes #6275 Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
@ -120,6 +120,21 @@ impl Command for Mv {
|
||||
));
|
||||
}
|
||||
|
||||
if source.is_dir() && destination.is_dir() {
|
||||
if let Some(name) = source.file_name() {
|
||||
let dst = destination.join(name);
|
||||
if dst.is_dir() {
|
||||
return Err(ShellError::GenericError(
|
||||
format!("Can't move {:?} to {:?}", source, dst),
|
||||
"Directory not empty".into(),
|
||||
Some(spanned_destination.span),
|
||||
None,
|
||||
Vec::new(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let some_if_source_is_destination = sources
|
||||
.iter()
|
||||
.find(|f| matches!(f, Ok(f) if destination.starts_with(f)));
|
||||
|
Reference in New Issue
Block a user