Use newer trap and tmpdir-creation framework.
[coreutils.git] / tests / cp / dir-rm-dest
blobc6c8229e531daf27c8ffecd737f3871bc27ebc2e
1 #!/bin/sh
2 # verify that cp's --remove-destination option works with -R
4 if test "$VERBOSE" = yes; then
5 set -x
6 cp --version
7 fi
9 pwd=`pwd`
10 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
11 trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
12 trap '(exit $?); exit' 1 2 13 15
14 framework_failure=0
15 mkdir -p $tmp || framework_failure=1
16 cd $tmp || framework_failure=1
17 mkdir d e || framework_failure=1
19 if test $framework_failure = 1; then
20 echo 'failure in testing framework'
21 exit 1
24 fail=0
26 # Do it once with no destination...
27 cp -R --remove-destination d e || fail=1
29 # ...and again, with an existing destination.
30 cp -R --remove-destination d e || fail=1
32 (exit $fail); exit $fail