2fc10b230679c39c22b494c8d9c3abf4d5b8f7ef
[platform/upstream/coreutils.git] / tests / cp / dir-slash
1 #!/bin/sh
2 # Make sure that cp -R DIR1 DIR2 does the right thing
3 # when DIR1 is written with a trailing slash.
4
5 if test "$VERBOSE" = yes; then
6   set -x
7   cp --version
8 fi
9
10 pwd=`pwd`
11 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
12 trap 'status=$?; cd $pwd; rm -rf $t0 || exit $?; exit $status' 0
13 trap 'exit $?' 1 2 13 15
14
15 framework_failure=0
16 mkdir -p $tmp || framework_failure=1
17 cd $tmp || framework_failure=1
18
19 mkdir dir1 dir2 || framework_failure=1
20 touch dir1/file || framework_failure=1
21
22 if test $framework_failure = 1; then
23   echo 'failure in testing framework'
24   exit 1
25 fi
26
27 fail=0
28 cp -R dir1/ dir2 || fail=1
29
30 # This file should not exist, but it did with fileutils-4.0w.
31 test -r dir2/file && fail=1
32
33 # These two should.
34 test -r dir2/dir1/file || fail=1
35 test -r dir1/file || fail=1
36
37 (exit $fail); exit $fail