2 # Ensure that cp/mv don't clobber a just-copied file.
3 # With fileutils-4.1 and earlier, this test would fail.
5 if test "$VERBOSE" = yes; then
11 . $srcdir/../envvar-check
12 . $srcdir/../lang-default
13 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
17 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
18 trap '(exit $?); exit' 1 2 13 15
21 mkdir $tmp || framework_failure=1
22 cd $tmp || framework_failure=1
23 mkdir a b c || framework_failure=1
24 echo a > a/f || framework_failure=1
25 echo b > b/f || framework_failure=1
27 if test $framework_failure = 1; then
28 echo 'failure in testing framework' 1>&2
34 cp a/f b/f c 2> /dev/null && fail=1
38 test "`cat c/f`" = a || fail=1
41 # With --backup=numbered, it should succeed
42 cp --backup=numbered a/f b/f c || fail=1
46 test -f c/f.~1~ || fail=1
49 mv a/f b/f c 2> /dev/null && fail=1
53 test "`cat c/f`" = a || fail=1
55 # Make sure mv still works when moving hard links.
56 # This is where the same_file test is necessary, and why
57 # we save file names in addition to dev/ino.
61 mv a/f b/g c || fail=1
68 mv a/f b/f b/g c 2> /dev/null && fail=1
69 test -f a/f && fail=1 # a/f should have been moved
70 test -f b/f || fail=1 # b/f should remain
71 test -f b/g && fail=1 # b/g should have been moved
75 (exit $fail); exit $fail