summaryrefslogtreecommitdiff
path: root/tests
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
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')
-rwxr-xr-xtests/cp/cp-i.sh10
-rwxr-xr-xtests/cp/preserve-link.sh2
-rwxr-xr-xtests/cp/slink-2-slink.sh4
-rwxr-xr-xtests/mv/i-1.pl2
-rwxr-xr-xtests/mv/i-5.sh2
-rwxr-xr-xtests/mv/mv-n.sh8
-rwxr-xr-xtests/mv/update.sh3
7 files changed, 16 insertions, 15 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
diff --git a/tests/mv/i-1.pl b/tests/mv/i-1.pl
index ac4d74640..f2ee0e9cc 100755
--- a/tests/mv/i-1.pl
+++ b/tests/mv/i-1.pl
@@ -32,7 +32,7 @@ my @Tests =
{IN => {src => "a\n"}}, {IN => {dst => "b\n"}}, '<', {IN => "n\n"},
{ERR => "mv: overwrite 'dst'? "},
{POST => sub { -r 'src' or die "test $test_a failed\n"}},
- {EXIT => 0},
+ {EXIT => 1},
],
);
diff --git a/tests/mv/i-5.sh b/tests/mv/i-5.sh
index 66e9cf067..fabb27514 100755
--- a/tests/mv/i-5.sh
+++ b/tests/mv/i-5.sh
@@ -24,6 +24,6 @@ touch b || framework_failure_
# coreutils 6.2 mv would neglect to prompt in this case.
-echo n | mv -i a b 2>/dev/null || fail=1
+echo n | returns_ 1 mv -i a b 2>/dev/null || fail=1
Exit $fail
diff --git a/tests/mv/mv-n.sh b/tests/mv/mv-n.sh
index 49db26841..fbf571368 100755
--- a/tests/mv/mv-n.sh
+++ b/tests/mv/mv-n.sh
@@ -27,7 +27,7 @@ echo "renamed 'a' -> 'b'" > out_move
# ask for overwrite, answer no
touch a b || framework_failure_
-echo n | mv -vi a b 2>/dev/null > out1 || fail=1
+echo n | returns_ 1 mv -vi a b 2>/dev/null > out1 || fail=1
compare out1 out_empty || fail=1
# ask for overwrite, answer yes
@@ -37,17 +37,17 @@ compare out2 out_move || fail=1
# -n wins (as the last option)
touch a b || framework_failure_
-echo y | mv -vin a b 2>/dev/null > out3 || fail=1
+echo y | returns_ 1 mv -vin a b 2>/dev/null > out3 || fail=1
compare out3 out_empty || fail=1
# -n wins (as the last option)
touch a b || framework_failure_
-echo y | mv -vfn a b 2>/dev/null > out4 || fail=1
+echo y | returns_ 1 mv -vfn a b 2>/dev/null > out4 || fail=1
compare out4 out_empty || fail=1
# -n wins (as the last option)
touch a b || framework_failure_
-echo y | mv -vifn a b 2>/dev/null > out5 || fail=1
+echo y | returns_ 1 mv -vifn a b 2>/dev/null > out5 || fail=1
compare out5 out_empty || fail=1
# options --backup and --no-clobber are mutually exclusive
diff --git a/tests/mv/update.sh b/tests/mv/update.sh
index d3ec6120c..f71297c2b 100755
--- a/tests/mv/update.sh
+++ b/tests/mv/update.sh
@@ -29,7 +29,8 @@ 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.
- $cp_or_mv $interactive --update old new < /dev/null > out 2>&1 || fail=1
+ returns_ 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