da50602ad9d4f400b593f50d7b354c998743d505
[platform/upstream/coreutils.git] / tests / cp / r-vs-symlink
1 #!/bin/sh
2 # cp -r should not create symlinks.  Fixed in fileutils-4.1.5.
3 # Restored old behavior (whereby cp -r preserves symlinks) in 4.1.6,
4 # though now such usage evokes a warning:
5 # cp: `slink': WARNING: using -r to copy symbolic links is not portable
6
7 if test "$VERBOSE" = yes; then
8   set -x
9   cp --version
10 fi
11
12 . $srcdir/../envvar-check
13
14 pwd=`pwd`
15 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
16 trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
17 trap '(exit $?); exit' 1 2 13 15
18
19 framework_failure=0
20 mkdir -p $tmp || framework_failure=1
21 cd $tmp || framework_failure=1
22 echo abc > foo || framework_failure=1
23 ln -s foo slink || framework_failure=1
24 ln -s no-such-file no-file || framework_failure=1
25
26 if test $framework_failure = 1; then
27   echo "$0: failure in testing framework" 1>&2
28   (exit 1); exit 1
29 fi
30
31 fail=0
32
33 # This would fail in 4.1.5, not in 4.1.6.
34 cp -r no-file junk 2>/dev/null || fail=1
35
36 cp -r slink bar 2>/dev/null || fail=1
37 set x `ls -l bar`; shift; mode=$1
38 case $mode in
39   l*) ;;
40   *) fail=1;;
41 esac
42
43 (exit $fail); exit $fail