c6c8229e531daf27c8ffecd737f3871bc27ebc2e
[platform/upstream/coreutils.git] / tests / cp / dir-rm-dest
1 #!/bin/sh
2 # verify that cp's --remove-destination option works with -R
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   cp --version
7 fi
8
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
13
14 framework_failure=0
15 mkdir -p $tmp || framework_failure=1
16 cd $tmp || framework_failure=1
17 mkdir d e || framework_failure=1
18
19 if test $framework_failure = 1; then
20   echo 'failure in testing framework'
21   exit 1
22 fi
23
24 fail=0
25
26 # Do it once with no destination...
27 cp -R --remove-destination d e || fail=1
28
29 # ...and again, with an existing destination.
30 cp -R --remove-destination d e || fail=1
31
32 (exit $fail); exit $fail