now silently does nothing if A exists.
[bug introduced with coreutils-7.1]
+** Changes in behavior
+
+ 'cp --force file symlink' now removes the symlink even if
+ it is self referential.
** Improvements
be opened for writing, the copy fails. However, with @option{--force},
when a destination file cannot be opened, @command{cp} then
tries to recreate the file by first removing it. Note @option{--force}
-alone will not remove symlinks that can't be traversed.
+alone will not remove dangling symlinks.
When this option is combined with
@option{--link} (@option{-l}) or @option{--symbolic-link}
(@option{-s}), the destination link is replaced, and unless
}
else
{
- if (errno != ENOENT)
+ if (errno == ELOOP && x->unlink_dest_after_failed_open)
+ /* leave new_dst=false so we unlink later. */;
+ else if (errno != ENOENT)
{
error (0, errno, _("cannot stat %s"), quoteaf (dst_name));
return false;
}
- new_dst = true;
+ else
+ new_dst = true;
}
}
# Starting with 6.9.90, this usage fails, by default:
for opt in '' '-f'; do
- cp $opt f dangle > err 2>&1 && fail=1
+ returns_ 1 cp $opt f dangle > err 2>&1 || fail=1
compare exp-err err || fail=1
test -f no-such && fail=1
done
+
# But you can set POSIXLY_CORRECT to get the historical behavior.
env POSIXLY_CORRECT=1 cp f dangle > out 2>&1 || fail=1
cat no-such >> out || fail=1
-
compare exp out || fail=1
+
+# Starting with 8.30 we treat ELOOP as existing and so
+# remove the symlink
+ln -s loop loop || framework_failure_
+cp -f f loop > err 2>&1 || fail=1
+compare /dev/null err || fail=1
+compare exp loop || fail=1
+test -f loop || fail=1
+
Exit $fail