Add/fix copyright notices and adjust to latest GNU FDL.
[platform/upstream/coreutils.git] / tests / cp / cp-parents
1 #!/bin/sh
2 # cp -R --parents dir-specified-with-trailing-slash/ other-dir
3 # would get a failed assertion.
4
5 # Copyright (C) 2000, 2002, 2004, 2005 Free Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21
22 if test "$VERBOSE" = yes; then
23   set -x
24   mv --version
25 fi
26
27 umask 022
28
29 pwd=`pwd`
30 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
31 trap 'status=$?; cd $pwd; exec 1>&2; rm -rf $t0 && exit $status' 0
32 trap '(exit $?); exit' 1 2 13 15
33
34 framework_failure=0
35
36 # Record absolute path of srcdir and cd back to current dir.
37 cd $srcdir || framework_failure=1
38 abs_srcdir=`pwd`
39 cd $pwd || framework_failure=1
40
41 . $srcdir/../envvar-check
42 . $srcdir/../umask-check
43
44 mkdir -p $tmp || framework_failure=1
45 cd $tmp || framework_failure=1
46
47 . $abs_srcdir/../setgid-check
48
49 mkdir foo bar || framework_failure=1
50 mkdir -p a/b/c d e || framework_failure=1
51
52 if test $framework_failure = 1; then
53   echo 'failure in testing framework'
54   exit 1
55 fi
56
57 fail=0
58
59 # With 4.0.37 and earlier (back to when?), this would fail
60 # with the failed assertion from dirname.c.
61 cp -R --parents foo/ bar || fail=1
62
63 # Exercise the make_path and re_protect code in cp.c.
64 # FIXME: compare verbose output with expected output.
65 cp --verbose -a --parents a/b/c d > /dev/null 2>&1 || fail=1
66 test -d d/a/b/c || fail=1
67
68 # Check that re_protect works.
69 chmod go=w d/a
70 cp -a --parents d/a/b/c e || fail=1
71 p=`ls -ld e/d|sed 's/ .*//'`; case $p in drwxr-xr-x);; *) fail=1;; esac
72 p=`ls -ld e/d/a|sed 's/ .*//'`; case $p in drwx-w--w-);; *) fail=1;; esac
73 p=`ls -ld e/d/a/b/c|sed 's/ .*//'`; case $p in drwxr-xr-x);; *) fail=1;; esac
74
75 (exit $fail); exit $fail