75fc7afc4fcfc2d5852f2c1ec0e01b264b22c39b
[platform/upstream/coreutils.git] / tests / cp / link-no-deref
1 #!/bin/sh
2 # Ensure that cp --link --no-dereference works properly
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   cp --version
7 fi
8
9 pwd=`pwd`
10 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
11 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
12 trap '(exit $?); exit $?' 1 2 13 15
13
14 framework_failure=0
15 mkdir -p $tmp || framework_failure=1
16 cd $tmp || framework_failure=1
17
18 ln -s no-such-file dangling-slink || framework_failure=1
19
20 if test $framework_failure = 1; then
21   echo "$0: failure in testing framework" 1>&2
22   (exit 1); exit 1
23 fi
24
25 fail=0
26
27 # Prior to coreutils-6.0, this would fail on non-Linux kernels,
28 # with link being applied to the dangling symlink.
29 cp --link --no-dereference dangling-slink d2 || fail=1
30
31 (exit $fail); exit $fail