]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp,mv: skipping due to -u is success, not failure
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 31 Jan 2023 17:24:43 +0000 (09:24 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 31 Jan 2023 17:25:25 +0000 (09:25 -0800)
This reverts the previous change, so that when a file
is skipped due to -u, this is not considered a failure.
* doc/coreutils.texi: Document this.
* src/copy.c (copy_internal): If --update says to skip,
treat this as success instead of failure.
* tests/mv/update.sh, tests/cp/slink-2-slink.sh:
Revert previous change, to match reverted behavior.

doc/coreutils.texi
src/copy.c
tests/cp/slink-2-slink.sh
tests/mv/update.sh

index da73503ed80ea67d56b54f6c184906a102201a61..143b93de9b793135ad34706060f4dcb2cfb37df5 100644 (file)
@@ -9191,8 +9191,8 @@ results in an error message on systems that do not support symbolic links.
 @opindex --update
 @cindex newer files, copying only
 Do not copy a non-directory that has an existing destination with the
-same or newer modification timestamp; silently fail instead.
-If timestamps are being preserved,
+same or newer modification timestamp; instead, silently skip the file
+without failing.  If timestamps are being preserved,
 the comparison is to the source timestamp truncated to the
 resolutions of the destination file system and of the system calls
 used to update timestamps; this avoids duplicate work if several
@@ -10124,7 +10124,8 @@ fail with a diagnostic instead of copying and then removing the file.
 @opindex --update
 @cindex newer files, moving only
 Do not move a non-directory that has an existing destination with the
-same or newer modification timestamp; silently fail instead.
+same or newer modification timestamp;
+instead, silently skip the file without failing.
 If the move is across file system boundaries, the comparison is to the
 source timestamp truncated to the resolutions of the destination file
 system and of the system calls used to update timestamps; this avoids
index f236afd2e2a8b99bf2f69f4df5057bd4a0cc527c..e16fedb28d8e3763b32bec0225be72170185bfa3 100644 (file)
@@ -2197,7 +2197,7 @@ copy_internal (char const *src_name, char const *dst_name,
                         }
                     }
 
-                  return false;
+                  return true;
                 }
             }
 
index ece8d393dd69f56bb2ab46a91af7512edf97120f..00e3feeb3178a7b21f9f02a26d12ae9f58da2818 100755 (executable)
@@ -26,7 +26,7 @@ ln -s file b || framework_failure_
 ln -s no-such-file c || framework_failure_
 ln -s no-such-file d || framework_failure_
 
-returns_ 1 cp --update --no-dereference a b || fail=1
-returns_ 1 cp --update --no-dereference c d || fail=1
+cp --update --no-dereference a b || fail=1
+cp --update --no-dereference c d || fail=1
 
 Exit $fail
index f71297c2ba919eb665c6a363da8a2006fd52c235..d3ec6120c51174d04fd9ddd3ca88f2b5a1b72025 100755 (executable)
@@ -29,8 +29,7 @@ for interactive in '' -i; do
     # This is a no-op, with no prompt.
     # With coreutils-6.9 and earlier, using --update with -i would
     # mistakenly elicit a prompt.
-    returns_ 1 $cp_or_mv $interactive --update old new </dev/null >out 2>&1 ||
-      fail=1
+    $cp_or_mv $interactive --update old new < /dev/null > out 2>&1 || fail=1
     compare /dev/null out || fail=1
     case "$(cat new)" in new) ;; *) fail=1 ;; esac
     case "$(cat old)" in old) ;; *) fail=1 ;; esac