1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Correct behavior of cp -r with non-existent dest

This commit is contained in:
Ian Douglas Scott 2017-08-09 15:35:13 -07:00
parent c827795d17
commit 13d97ee1cc
No known key found for this signature in database
GPG key ID: 4924E10E199B5959

View file

@ -726,7 +726,12 @@ fn copy_directory(root: &Path, target: &Target, options: &Options) -> CopyResult
}
let root_path = Path::new(&root).canonicalize()?;
let root_parent = root_path.parent();
let root_parent = if target.exists() {
root_path.parent()
} else {
Some(root_path.as_path())
};
for path in WalkDir::new(root) {
let path = or_continue!(or_continue!(path).path().canonicalize());