coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

cp: symlink-overwrite error-priority is wrong

Open BenWiederhake opened this issue 1 year ago • 0 comments

Steps to reproduce:

  • Create two regular files, README.md and good/README.md, and a directory target/ that does not contain anything named README.md.
  • chdir into target/.
  • Try to copy in symlink-mode the files ../README.md and ../good/README.md to 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

BenWiederhake avatar Apr 24 '24 01:04 BenWiederhake