doc: move @shortcontents and @contents from end to start
[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, 2006-2008 Free Software
6 # Foundation, Inc.
7
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21 if test "$VERBOSE" = yes; then
22   set -x
23   mv --version
24 fi
25
26 . $srcdir/test-lib.sh
27
28 working_umask_or_skip_
29
30 # Run the setgid check from the just-created directory.
31 . "$abs_srcdir/setgid-check"
32
33 mkdir foo bar || framework_failure
34 mkdir -p a/b/c d e g || framework_failure
35 ln -s d/a sym || framework_failure
36 touch f || framework_failure
37
38 fail=0
39
40 # With 4.0.37 and earlier (back to when?), this would fail
41 # with the failed assertion from dirname.c.
42 cp -R --parents foo/ bar || fail=1
43
44 # Exercise the make_path and re_protect code in cp.c.
45 # FIXME: compare verbose output with expected output.
46 cp --verbose -a --parents a/b/c d > /dev/null 2>&1 || fail=1
47 test -d d/a/b/c || fail=1
48
49 # With 6.7 and earlier, cp --parents f/g d would mistakenly create a
50 # directory d/f, even though f is a regular file.
51 cp --parents f/g d 2>/dev/null && fail=1
52 test -d d/f && fail=1
53
54 # Check that re_protect works.
55 chmod go=w d/a
56 cp -a --parents d/a/b/c e || fail=1
57 cp -a --parents sym/b/c g || fail=1
58 p=`ls -ld e/d|cut -b-10`; case $p in drwxr-xr-x);; *) fail=1;; esac
59 p=`ls -ld e/d/a|cut -b-10`; case $p in drwx-w--w-);; *) fail=1;; esac
60 p=`ls -ld g/sym|cut -b-10`; case $p in drwx-w--w-);; *) fail=1;; esac
61 p=`ls -ld e/d/a/b/c|cut -b-10`; case $p in drwxr-xr-x);; *) fail=1;; esac
62 p=`ls -ld g/sym/b/c|cut -b-10`; case $p in drwxr-xr-x);; *) fail=1;; esac
63
64 Exit $fail