cp: allow directory merging when destination was just created
Previously, when copying to a destination that was created in the same
cp call, the operation would fail with "will not overwrite just-created"
for both files and directories. This change allows directories to be
merged (matching GNU cp behavior) while still preventing file
overwrites.
The fix checks if both the source and destination are directories
before allowing the merge. If either is a file, the original error
behavior is preserved to prevent accidental file overwrites.
Fixes the case where copying multiple directories to the same
destination path would incorrectly error instead of merging their
contents.
fixes: #9318
efcdbfe
3 days ago
by vikram-kangotra
-0.02%
test_cp: Update with the suggestion
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>