summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-05-23 14:52:32 +0000
committerJim Meyering <jim@meyering.net>1999-05-23 14:52:32 +0000
commit0868b5794a6d6579509b4a8e5305328ccb4400ce (patch)
tree720c8dc0989879e39450c8d9c01ccb1d20dc1646
parent46945ad760173515e01c2ca718fc68a4c7e2345b (diff)
downloadcoreutils-0868b5794a6d6579509b4a8e5305328ccb4400ce.tar.xz
(copy_internal): Make it so `mv -f FILE FILE' does not remove FILE.
Based on a patch from Chris Yeo.
-rw-r--r--src/copy.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/copy.c b/src/copy.c
index fe68d49f4..9246aa07e 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -568,6 +568,13 @@ copy_internal (const char *src_path, const char *dst_path,
}
else
{
+ if (SAME_INODE (src_sb, dst_sb))
+ {
+ error (0, 0, _("`%s' and `%s' are the same file"),
+ src_path, dst_path);
+ return 1;
+ }
+
if (unlink (dst_path) && errno != ENOENT)
{
error (0, errno, _("cannot remove old link to `%s'"),