From 01503ce7319b099d9deaeab43628e1b2b07a874a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 31 Jan 2023 09:24:43 -0800 Subject: [PATCH] cp,mv: skipping due to -u is success, not failure 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 | 7 ++++--- src/copy.c | 2 +- tests/cp/slink-2-slink.sh | 4 ++-- tests/mv/update.sh | 3 +-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index da73503ed..143b93de9 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -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 diff --git a/src/copy.c b/src/copy.c index f236afd2e..e16fedb28 100644 --- a/src/copy.c +++ b/src/copy.c @@ -2197,7 +2197,7 @@ copy_internal (char const *src_name, char const *dst_name, } } - return false; + return true; } } diff --git a/tests/cp/slink-2-slink.sh b/tests/cp/slink-2-slink.sh index ece8d393d..00e3feeb3 100755 --- a/tests/cp/slink-2-slink.sh +++ b/tests/cp/slink-2-slink.sh @@ -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 diff --git a/tests/mv/update.sh b/tests/mv/update.sh index f71297c2b..d3ec6120c 100755 --- a/tests/mv/update.sh +++ b/tests/mv/update.sh @@ -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 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 -- 2.37.2