summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2023-04-07 10:25:41 +0100
committerPádraig Brady <P@draigBrady.com>2023-04-08 12:11:58 +0100
commitf6c21f6d3addb6461c41af612e73fbb15d21545f (patch)
treed5079976206a43071ddd160672f95a200513adf1 /tests
parentdb28af406f311ac8f78604cc5906613866aecef5 (diff)
downloadcoreutils-f6c21f6d3addb6461c41af612e73fbb15d21545f.tar.gz
cp,mv: issue "skipped" messages when skipping files
* NEWS: Mention the change in behavior to issue a "not replaced" error diagnostic with -n, and the "skipped" message with -v. * src/copy.c (copy_internal): Adjust to output the "skipped" messages depending on -i, -n, -u. * tests/cp/cp-i.sh: Adjust accordingly. * tests/mv/mv-n.sh: Likewise.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/cp/cp-i.sh17
-rwxr-xr-xtests/mv/mv-n.sh14
2 files changed, 23 insertions, 8 deletions
diff --git a/tests/cp/cp-i.sh b/tests/cp/cp-i.sh
index b137bc4a5..4458b2edd 100755
--- a/tests/cp/cp-i.sh
+++ b/tests/cp/cp-i.sh
@@ -28,12 +28,14 @@ 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
-> out_empty
+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_empty || fail=1
+compare out1 out_skip || fail=1
# ask for overwrite, answer yes
echo y | cp -vi c d 2>/dev/null > out2 || fail=1
@@ -45,6 +47,11 @@ 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
+
+# -n wins over -i non verbose
+echo y | returns_ 1 cp -in c d 2>err4 > out4 || fail=1
+compare err4 err_skip || fail=1
compare out4 out_empty || fail=1
# ask for overwrite, answer yes
@@ -53,11 +60,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_empty || fail=1
+compare out6 out_skip || 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_empty || fail=1
+compare out7 out_skip || fail=1
# options --backup and --no-clobber are mutually exclusive
returns_ 1 cp -bn c d 2>/dev/null || fail=1
diff --git a/tests/mv/mv-n.sh b/tests/mv/mv-n.sh
index fbf571368..45d74eb93 100755
--- a/tests/mv/mv-n.sh
+++ b/tests/mv/mv-n.sh
@@ -23,12 +23,14 @@ 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_empty || fail=1
+compare out1 out_skip || fail=1
# ask for overwrite, answer yes
touch a b || framework_failure_
@@ -38,17 +40,23 @@ 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
+
+# -n wins (non verbose)
+touch a b || framework_failure_
+echo y | returns_ 1 mv -in a b 2>err3 > out3 || fail=1
compare out3 out_empty || fail=1
+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_empty || fail=1
+compare out4 out_skip || 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_empty || fail=1
+compare out5 out_skip || fail=1
# options --backup and --no-clobber are mutually exclusive
touch a || framework_failure_