]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp: 'cp -il A B' no longer fails if user OKs it
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 Oct 2018 19:19:43 +0000 (12:19 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 Oct 2018 19:38:34 +0000 (12:38 -0700)
* NEWS: Mention the change.
* src/copy.c (copy_internal): Replace the link if the
user has okayed it.

NEWS
src/copy.c

diff --git a/NEWS b/NEWS
index 77c26df4d7f2e6fdbb3a67ff1c67749810d5330c..0fea1a118612ff1040f783541ea84c7316062840 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  When B already exists, 'cp -il A B' no longer immediately fails
+  after asking the user whether to proceed.
+  [This bug was present in "the beginning".]
+
   df no longer corrupts displayed multibyte characters on macOS.
 
 ** New features
index 1a9cdd1a8e5919e5988c1b6747e286c290fbd79a..417147bc2bc34a6748152e94cf1eccb5d8eabbce 100644 (file)
@@ -2657,9 +2657,9 @@ copy_internal (char const *src_name, char const *dst_name,
            && !(! CAN_HARDLINK_SYMLINKS && S_ISLNK (src_mode)
                 && x->dereference == DEREF_NEVER))
     {
-      if (! create_hard_link (src_name, dst_name,
-                              x->unlink_dest_after_failed_open,
-                              false, dereference))
+      bool replace = (x->unlink_dest_after_failed_open
+                      || x->interactive == I_ASK_USER);
+      if (! create_hard_link (src_name, dst_name, replace, false, dereference))
         goto un_backup;
     }
   else if (S_ISREG (src_mode)