]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp: actually support --update=none-fail
authorPádraig Brady <P@draigBrady.com>
Fri, 3 May 2024 09:18:50 +0000 (10:18 +0100)
committerPádraig Brady <P@draigBrady.com>
Fri, 3 May 2024 09:18:50 +0000 (10:18 +0100)
* src/cp.c: Add the entries for the --update=none-fail option.
* tests/mv/update.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/70727

NEWS
src/cp.c
tests/mv/update.sh

diff --git a/NEWS b/NEWS
index 389f7251692556e276a09a8cad577f6f90830bed..7e8ccb34f76a200a150b3ad88389e540bb74af76 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  cp fixes support for --update=none-fail, which would have been
+  rejected as an invalid option.
+  [bug introduced in coreutils-9.5]
+
   ls and printf fix shell quoted output in the edge case of escaped
   first and last characters, and single quotes in the string.
   [bug introduced in coreutils-8.26]
index 28b0217db132453d46d45261cb31cb35865b7ac2..06dbad155cdb07798f5cdd9ba49208cb15381513 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -104,11 +104,11 @@ ARGMATCH_VERIFY (reflink_type_string, reflink_type);
 
 static char const *const update_type_string[] =
 {
-  "all", "none", "older", nullptr
+  "all", "none", "none-fail", "older", nullptr
 };
 static enum Update_type const update_type[] =
 {
-  UPDATE_ALL, UPDATE_NONE, UPDATE_OLDER,
+  UPDATE_ALL, UPDATE_NONE, UPDATE_NONE_FAIL, UPDATE_OLDER,
 };
 ARGMATCH_VERIFY (update_type_string, update_type);
 
index 16435780369bcfbc3a232ff25d28202c83ef1a63..39ff677b9288c43079aac2d0c97baf2656cc3e5c 100755 (executable)
@@ -38,6 +38,17 @@ for interactive in '' -i; do
   done
 done
 
+# These should accept all options
+for update_option in '--update' '--update=older' '--update=all' \
+ '--update=none' '--update=none-fail'; do
+
+  touch file1 || framework_failure_
+  mv $update_option file1 file2 || fail=1
+  test -f file1 && fail=1
+  cp $update_option file2 file1 || fail=1
+  rm file1 file2 || framework_failure_
+done
+
 # These should perform the rename / copy
 for update_option in '--update' '--update=older' '--update=all' \
  '--update=none --update=all'; do