-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Steps to reproduce:
- Create two regular files,
README.md
andgood/README.md
, and an initially-empty directorytmp/
. - Inside
tmp
, create an empty regular filefoo
, and a symlinkREADME.md
that points tofoo
. - Try to copy
README.md
andgood/README.md
totmp/
Expected result: README.md
is copied to tmp/
into the file foo
, and the second attempt is aborted, leading to an error message and a non-zero (failure) exit code.
Actual result: README.md
is copied to tmp/
into the file foo
, and the second attempt is successful, leading to foo
containing the contents of the second file, no error message, and a zero (success) exit code.
Demonstrator:
$ mkdir -p good && cp README.md good/README.md
$ rm -rf tmp/ && mkdir tmp/ && ln -s foo tmp/README.md && touch tmp/foo
$ ../gnu/src/cp README.md good/README.md tmp # Yes error!
../gnu/src/cp: will not copy 'good/README.md' through just-created symlink 'tmp/README.md'
[$? = 1]
$
$ mkdir -p good && cp README.md good/README.md
$ rm -rf tmp/ && mkdir tmp/ && ln -s foo tmp/README.md && touch tmp/foo
$ cargo run cp README.md good/README.md tmp # No error?!
$
Found while reviewing #6208