]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(copy_internal): Don't explicitly unlink the destination
authorJim Meyering <jim@meyering.net>
Thu, 11 May 2006 07:33:00 +0000 (07:33 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 11 May 2006 07:33:00 +0000 (07:33 +0000)
when moving a symlink into the place of an existing non-directory.
Reported by Joshua Hudson.

src/copy.c

index e966a951bcb6d0486e4cdc9c02c142dd1185d67c..645b90b468fd73ba6fc67199846eaeb177a9114f 100644 (file)
@@ -1230,8 +1230,10 @@ copy_internal (char const *src_name, char const *dst_name,
          else if (! S_ISDIR (dst_sb.st_mode)
                   && (x->unlink_dest_before_opening
                       || (x->preserve_links && 1 < dst_sb.st_nlink)
-                      || (x->dereference == DEREF_NEVER
-                          && S_ISLNK (src_sb.st_mode))))
+                      || (!x->move_mode
+                          && x->dereference == DEREF_NEVER
+                          && S_ISLNK (src_sb.st_mode))
+                      ))
            {
              if (unlink (dst_name) != 0 && errno != ENOENT)
                {