Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / cp / r-vs-symlink
1 #!/bin/sh
2 # cp -r should not create symlinks.  Fixed in fileutils-4.1.5.
3
4 # Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21 # Restored old behavior (whereby cp -r preserves symlinks) in 4.1.6,
22 # though now such usage evokes a warning:
23 # cp: `slink': WARNING: using -r to copy symbolic links is not portable
24
25 if test "$VERBOSE" = yes; then
26   set -x
27   cp --version
28 fi
29
30 . $srcdir/../envvar-check
31
32 pwd=`pwd`
33 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
34 trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
35 trap '(exit $?); exit' 1 2 13 15
36
37 framework_failure=0
38 mkdir -p $tmp || framework_failure=1
39 cd $tmp || framework_failure=1
40 echo abc > foo || framework_failure=1
41 ln -s foo slink || framework_failure=1
42 ln -s no-such-file no-file || framework_failure=1
43
44 if test $framework_failure = 1; then
45   echo "$0: failure in testing framework" 1>&2
46   (exit 1); exit 1
47 fi
48
49 fail=0
50
51 # This would fail in 4.1.5, not in 4.1.6.
52 cp -r no-file junk 2>/dev/null || fail=1
53
54 cp -r slink bar 2>/dev/null || fail=1
55 set x `ls -l bar`; shift; mode=$1
56 case $mode in
57   l*) ;;
58   *) fail=1;;
59 esac
60
61 (exit $fail); exit $fail