]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
copy: reduce verbosity of -i and -u with --verbose
authorPádraig Brady <P@draigBrady.com>
Tue, 25 Apr 2023 10:07:36 +0000 (11:07 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 25 Apr 2023 10:17:54 +0000 (11:17 +0100)
Since skipping of files is central to the operation of -i and -u,
and with -u one may be updating few files out of many,
reinstate the verbosity of this functionality as it was before 9.3.

* src/copy.c (copy_internal): Only output "skipped" message
with --debug.  Also adjust so message never changes with --debug.
* tests/cp/cp-i.sh: Adjust accordingly.
* tests/mv/mv-n.sh: Likewise.
* tests/cp/debug.sh: Add explicit test case for message.
* NEWS: Mention the change in behavior.

NEWS
src/copy.c
tests/cp/cp-i.sh
tests/cp/debug.sh
tests/mv/mv-n.sh

diff --git a/NEWS b/NEWS
index 0590dd13a02c7384e572565d82bccbf3b3214c2a..f6f79ae530990fe3171d2dd300ffeabf57f50565 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,12 @@ GNU coreutils NEWS                                    -*- outline -*-
   factor, numfmt, and tsort now diagnose read errors on the input.
   [This bug was present in "the beginning".]
 
+** Changes in behavior
+
+  'cp -v' and 'mv -v' will no longer output a message for each file skipped
+  due to -i, or -u.  Instead they only output this information with --debug.
+  I.e., 'cp -u -v' etc. will have the same verbosity as before coreutils-9.3.
+
 
 * Noteworthy changes in release 9.3 (2023-04-18) [stable]
 
index 13d93324f4d6ca8006f2cb86e4f8eb77d8880f4a..0dd059d2e437f88d650bb7ce5b0239dab589d831 100644 (file)
@@ -2433,10 +2433,10 @@ copy_internal (char const *src_name, char const *dst_name,
 skip:
           if (skipped)
             {
-              if (x->verbose)
-                printf (_("skipped %s\n"), quoteaf (dst_name));
-              else if (x->interactive == I_ALWAYS_NO)
+              if (x->interactive == I_ALWAYS_NO)
                 error (0, 0, _("not replacing %s"), quoteaf (dst_name));
+              else if (x->debug)
+                printf (_("skipped %s\n"), quoteaf (dst_name));
 
               return_now = true;
             }
index 4458b2edd62e61edf28aba42a5bf2fe0fe6a7a2b..a9178a99e1e91113ddd2df677753248163d27702 100755 (executable)
@@ -29,13 +29,12 @@ echo n | returns_ 1 cp -iR a b 2>/dev/null || fail=1
 # test miscellaneous combinations of -f -i -n parameters
 touch c d || framework_failure_
 echo "'c' -> 'd'" > out_copy || framework_failure_
-echo "skipped 'd'" > out_skip || framework_failure_
 echo "cp: not replacing 'd'" > err_skip || framework_failure_
 touch out_empty || framework_failure_
 
 # ask for overwrite, answer no
 echo n | returns_ 1 cp -vi  c d 2>/dev/null > out1 || fail=1
-compare out1 out_skip || fail=1
+compare out1 out_empty || fail=1
 
 # ask for overwrite, answer yes
 echo y | cp -vi  c d 2>/dev/null > out2 || fail=1
@@ -47,7 +46,7 @@ compare out3 out_copy  || fail=1
 
 # -n wins over -i
 echo y | returns_ 1 cp -vin c d 2>/dev/null > out4 || fail=1
-compare out4 out_skip || fail=1
+compare out4 out_empty || fail=1
 
 # -n wins over -i non verbose
 echo y | returns_ 1 cp -in c d 2>err4 > out4 || fail=1
@@ -60,11 +59,11 @@ compare out5 out_copy  || fail=1
 
 # do not ask, prevent from overwrite
 echo n | returns_ 1 cp -vfn c d 2>/dev/null > out6 || fail=1
-compare out6 out_skip || fail=1
+compare out6 out_empty || fail=1
 
 # do not ask, prevent from overwrite
 echo n | returns_ 1 cp -vnf c d 2>/dev/null > out7 || fail=1
-compare out7 out_skip || fail=1
+compare out7 out_empty || fail=1
 
 # options --backup and --no-clobber are mutually exclusive
 returns_ 1 cp -bn c d 2>/dev/null || fail=1
index b46adc637f6e00a4be4d0e711fcf30f2df185482..242894de2fce22f1542538d77fdc6c700bde2901 100755 (executable)
@@ -25,4 +25,8 @@ grep 'copy offload:.*reflink:.*sparse detection:' cp.out || fail=1
 cp --debug --attributes-only file file.cp >cp.out || fail=1
 returns_ 1 grep 'copy offload:.*reflink:.*sparse detection:' cp.out || fail=1
 
+touch file.cp || framework_failure_
+cp --debug --update=none file file.cp >cp.out || fail=1
+grep 'skipped' cp.out || fail=1
+
 Exit $fail
index 45d74eb9381c9afce12f6215207e48b67118b7d9..60547807c24288938d3304083cc57b0b665afeae 100755 (executable)
@@ -23,14 +23,13 @@ print_ver_ mv
 # test miscellaneous combinations of -f -i -n parameters
 touch a b || framework_failure_
 echo "renamed 'a' -> 'b'" > out_move
-echo "skipped 'b'" > out_skip || framework_failure_
 echo "mv: not replacing 'b'" > err_skip || framework_failure_
 > out_empty
 
 # ask for overwrite, answer no
 touch a b || framework_failure_
 echo n | returns_ 1 mv -vi a b 2>/dev/null > out1 || fail=1
-compare out1 out_skip || fail=1
+compare out1 out_empty || fail=1
 
 # ask for overwrite, answer yes
 touch a b || framework_failure_
@@ -40,7 +39,7 @@ compare out2 out_move || fail=1
 # -n wins (as the last option)
 touch a b || framework_failure_
 echo y | returns_ 1 mv -vin a b 2>/dev/null > out3 || fail=1
-compare out3 out_skip || fail=1
+compare out3 out_empty || fail=1
 
 # -n wins (non verbose)
 touch a b || framework_failure_
@@ -51,12 +50,12 @@ compare err3 err_skip || fail=1
 # -n wins (as the last option)
 touch a b || framework_failure_
 echo y | returns_ 1 mv -vfn a b 2>/dev/null > out4 || fail=1
-compare out4 out_skip || fail=1
+compare out4 out_empty || fail=1
 
 # -n wins (as the last option)
 touch a b || framework_failure_
 echo y | returns_ 1 mv -vifn a b 2>/dev/null > out5 || fail=1
-compare out5 out_skip || fail=1
+compare out5 out_empty || fail=1
 
 # options --backup and --no-clobber are mutually exclusive
 touch a || framework_failure_