maint: update all copyright year number ranges
[coreutils.git] / tests / cp / cp-parents.sh
blobde9b0f779e63a64aed677f4a9070a6053e7e0e47
1 #!/bin/sh
3 # Copyright (C) 2000-2017 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
19 print_ver_ cp
21 working_umask_or_skip_
23 # Run the setgid check from the just-created directory.
24 skip_if_setgid_
27 mkdir foo bar
28 mkdir -p a/b/c d e g
29 ln -s d/a sym
30 touch f
31 } || framework_failure_
33 # With 4.0.37 and earlier (back to when?), this would fail
34 # with the failed assertion from dirname.c due to the trailing slash.
35 cp -R --parents foo/ bar || fail=1
37 # Exercise the make_path and re_protect code in cp.c.
38 # FIXME: compare verbose output with expected output.
39 cp --verbose -a --parents a/b/c d > /dev/null 2>&1 || fail=1
40 test -d d/a/b/c || fail=1
42 # With 6.7 and earlier, cp --parents f/g d would mistakenly create a
43 # directory d/f, even though f is a regular file.
44 returns_ 1 cp --parents f/g d 2>/dev/null || fail=1
45 test -d d/f && fail=1
47 # Check that re_protect works.
48 chmod go=w d/a || framework_failure_
49 cp -a --parents d/a/b/c e || fail=1
50 cp -a --parents sym/b/c g || fail=1
51 p=$(ls -ld e/d|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac
52 p=$(ls -ld e/d/a|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac
53 p=$(ls -ld g/sym|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac
54 p=$(ls -ld e/d/a/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac
55 p=$(ls -ld g/sym/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac
57 # Before 8.25 cp --parents --no-preserve=mode would copy
58 # the mode bits from the source directories
60 mkdir -p np/b &&
61 chmod 0700 np &&
62 touch np/b/file &&
63 chmod 775 np/b/file &&
64 mkdir np_dest
65 } || framework_failure_
66 cp --parents --no-preserve=mode np/b/file np_dest/ || fail=1
67 p=$(ls -ld np_dest/np|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac
69 Exit $fail