coreutils
coreutils copied to clipboard
cp: symlink-overwrite error-priority is wrong
Steps to reproduce:
- Create two regular files,
README.mdandgood/README.md, and a directorytarget/that does not contain anything namedREADME.md. - chdir into
target/. - Try to copy in symlink-mode the files
../README.mdand../good/README.mdto the current directory
Expected result: The first copy is successful, the second copy is refused with an error message that acknowledges that README.md was just created and must not be recreated.
Actual result: The first copy is successful, the second copy is refused with an error message that treats the newly-created README.md symlink as a file that always existed.
This also feels like it might lead to some other unexpected behavior, but I can't get it to do something worse like overwrite pointed-to files.
Demonstrator:
coreutils$ cd target/
coreutils/target$ rm -f README.md && ../../gnu/src/cp -s ../README.md ../good/README.md .
../../gnu/src/cp: will not overwrite just-created './README.md' with '../good/README.md'
[$? = 1]
coreutils/target$ rm -f README.md && cargo run cp -s ../README.md ../good/README.md .
cp: will not copy '../good/README.md' through just-created symlink './README.md'
[$? = 1]
$
Found while reviewing #6208