f55d49dff6b277eab92f0eee89984b449ec6fcae
[platform/upstream/coreutils.git] / tests / cp / symlink-slash
1 #!/bin/sh
2 # Make sure that cp -dR dereferences a symlink arg if its name is
3 # written with a trailing slash.
4
5 if test "$VERBOSE" = yes; then
6   set -x
7   cp --version
8 fi
9
10 . $srcdir/../envvar-check
11 . $srcdir/../lang-default
12
13 pwd=`pwd`
14 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
15 trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
16 trap '(exit $?); exit' 1 2 13 15
17
18 framework_failure=0
19 mkdir -p $tmp || framework_failure=1
20 cd $tmp || framework_failure=1
21
22 mkdir dir || framework_failure=1
23 ln -s dir symlink || framework_failure=1
24
25 if test $framework_failure = 1; then
26   echo 'failure in testing framework'
27   exit 1
28 fi
29
30 fail=0
31 cp -dR symlink/ s || fail=1
32 set `ls -l s`
33
34 # Prior to fileutils-4.0q, the following would have output ...`s -> dir'
35 # because the trailing slash was removed unconditionally (now you have to
36 # use the new --strip-trailing-slash option) causing cp to reproduce the
37 # symlink.  Now, the trailing slash is interpreted by the stat library
38 # call and so cp ends up dereferencing the symlink and copying the directory.
39 test "$*" = 'total 0' && : || fail=1
40
41 (exit $fail); exit $fail