summaryrefslogtreecommitdiff
path: root/tests/cp
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2023-01-31 08:46:21 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2023-01-31 08:54:37 -0800
commit7a69df88999bedd8e9fccf9f3dfa9ac6907fab66 (patch)
tree0c0440fedeefcf03cc31424281f29af768aa0ff6 /tests/cp
parent666a7fc1d5075807eac7e70f333febf1b99ee980 (diff)
downloadcoreutils-7a69df88999bedd8e9fccf9f3dfa9ac6907fab66.tar.gz
cp,ln,mv: when skipping exit with nonzero status
* NEWS, doc/coreutils.texi: Document this. * src/copy.c (copy_internal): * src/ln.c (do_link): Return false when skipping action due to --interactive or --no-clobber. * tests/cp/cp-i.sh, tests/cp/preserve-link.sh: * tests/cp/slink-2-slink.sh, tests/mv/i-1.pl, tests/mv/i-5.sh: * tests/mv/mv-n.sh, tests/mv/update.sh: Adjust expectations of exit status to match revised behavior.
Diffstat (limited to 'tests/cp')
-rwxr-xr-xtests/cp/cp-i.sh10
-rwxr-xr-xtests/cp/preserve-link.sh2
-rwxr-xr-xtests/cp/slink-2-slink.sh4
3 files changed, 8 insertions, 8 deletions
diff --git a/tests/cp/cp-i.sh b/tests/cp/cp-i.sh
index 6fbc31760..b137bc4a5 100755
--- a/tests/cp/cp-i.sh
+++ b/tests/cp/cp-i.sh
@@ -24,7 +24,7 @@ touch a/c || framework_failure_
# coreutils 6.2 cp would neglect to prompt in this case.
-echo n | cp -iR a b 2>/dev/null || fail=1
+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_
@@ -32,7 +32,7 @@ echo "'c' -> 'd'" > out_copy
> out_empty
# ask for overwrite, answer no
-echo n | cp -vi c d 2>/dev/null > out1 || fail=1
+echo n | returns_ 1 cp -vi c d 2>/dev/null > out1 || fail=1
compare out1 out_empty || fail=1
# ask for overwrite, answer yes
@@ -44,7 +44,7 @@ echo y | cp -vni c d 2>/dev/null > out3 || fail=1
compare out3 out_copy || fail=1
# -n wins over -i
-echo y | cp -vin c d 2>/dev/null > out4 || fail=1
+echo y | returns_ 1 cp -vin c d 2>/dev/null > out4 || fail=1
compare out4 out_empty || fail=1
# ask for overwrite, answer yes
@@ -52,11 +52,11 @@ echo y | cp -vfi c d 2>/dev/null > out5 || fail=1
compare out5 out_copy || fail=1
# do not ask, prevent from overwrite
-echo n | cp -vfn c d 2>/dev/null > out6 || fail=1
+echo n | returns_ 1 cp -vfn c d 2>/dev/null > out6 || fail=1
compare out6 out_empty || fail=1
# do not ask, prevent from overwrite
-echo n | cp -vnf c d 2>/dev/null > out7 || fail=1
+echo n | returns_ 1 cp -vnf c d 2>/dev/null > out7 || fail=1
compare out7 out_empty || fail=1
# options --backup and --no-clobber are mutually exclusive
diff --git a/tests/cp/preserve-link.sh b/tests/cp/preserve-link.sh
index eb83b0f2b..2adaffd44 100755
--- a/tests/cp/preserve-link.sh
+++ b/tests/cp/preserve-link.sh
@@ -81,7 +81,7 @@ for f in f linkm; do
# Copy all the hard links across. With cp from coreutils-8.12
# and prior, it would sometimes mistakenly copy rather than link.
- cp -au s t || fail=1
+ returns_ 1 cp -au s t || fail=1
same_inode t/s/f t/s/linkm || fail=1
same_inode t/s/f t/s/linke || fail=1
diff --git a/tests/cp/slink-2-slink.sh b/tests/cp/slink-2-slink.sh
index 00e3feeb3..ece8d393d 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_
-cp --update --no-dereference a b || fail=1
-cp --update --no-dereference c d || fail=1
+returns_ 1 cp --update --no-dereference a b || fail=1
+returns_ 1 cp --update --no-dereference c d || fail=1
Exit $fail