cp: with --force; replace self referential symlinks
commitc732388fa1a47376c28bc4a55eadd73944ab711d
authorPádraig Brady <P@draigBrady.com>
Wed, 16 May 2018 06:41:36 +0000 (15 23:41 -0700)
committerPádraig Brady <P@draigBrady.com>
Fri, 18 May 2018 03:52:09 +0000 (17 20:52 -0700)
treea4cf85b2abb64697de4c44e4732220a9cac6a664
parentd3daa95096e2692e5c8a0402e270b0e2ec7918e5
cp: with --force; replace self referential symlinks

* src/copy.c (copy_internal): Don't fail immediately upon
getting ELOOP when running stat() on the destination,
rather proceeding if -f specified, allowing the link
to be removed.  If the loop is not in the final component
of the destination path, we still fail but at the
subsequent unlink() stage.
* doc/coreutils.texi (cp invocation): Adjust wording to say
that --force doesn't work with dangling links, rather than
all links that can't be traversed.
* tests/cp/thru-dangling.sh: Add a test case.
* NEWS: Mention the change in behavior.
Discussed in https://bugs.gnu.org/31335
NEWS
doc/coreutils.texi
src/copy.c
tests/cp/thru-dangling.sh