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
21 working_umask_or_skip_
23 # Run the setgid check from the just-created directory.
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
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
63 chmod 775 np
/b
/file &&
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