tests: convert nearly all `...` expressions to $(...)
[coreutils.git] / tests / cp / cp-parents
blobb325c722b87c072baf3d43dcda4c52b243ad64d5
1 #!/bin/sh
2 # cp -R --parents dir-specified-with-trailing-slash/ other-dir
3 # would get a failed assertion.
5 # Copyright (C) 2000-2012 Free Software Foundation, Inc.
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 3 of the License, or
10 # (at your option) any later version.
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.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 . "${srcdir=.}/init.sh"; path_prepend_ ../src
21 print_ver_ mv
23 working_umask_or_skip_
25 # Run the setgid check from the just-created directory.
26 skip_if_setgid_
28 mkdir foo bar || framework_failure_
29 mkdir -p a/b/c d e g || framework_failure_
30 ln -s d/a sym || framework_failure_
31 touch f || framework_failure_
34 # With 4.0.37 and earlier (back to when?), this would fail
35 # with the failed assertion from dirname.c.
36 cp -R --parents foo/ bar || fail=1
38 # Exercise the make_path and re_protect code in cp.c.
39 # FIXME: compare verbose output with expected output.
40 cp --verbose -a --parents a/b/c d > /dev/null 2>&1 || fail=1
41 test -d d/a/b/c || fail=1
43 # With 6.7 and earlier, cp --parents f/g d would mistakenly create a
44 # directory d/f, even though f is a regular file.
45 cp --parents f/g d 2>/dev/null && fail=1
46 test -d d/f && fail=1
48 # Check that re_protect works.
49 chmod go=w d/a || framework_failure_
50 cp -a --parents d/a/b/c e || fail=1
51 cp -a --parents sym/b/c g || fail=1
52 p=$(ls -ld e/d|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac
53 p=$(ls -ld e/d/a|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac
54 p=$(ls -ld g/sym|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac
55 p=$(ls -ld e/d/a/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac
56 p=$(ls -ld g/sym/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac
58 Exit $fail