663b9da4ec20484411465862b9fc6e8b19d9b5a4
[platform/upstream/coreutils.git] / tests / cp / link
1 #!/bin/sh
2 # Make sure cp --link -f works when the target exists.
3 # This failed for 4.0z (due to a bug introduced in that test release).
4
5 if test "$VERBOSE" = yes; then
6   set -x
7   cp --version
8 fi
9
10 pwd=`pwd`
11 tmp=cp-link.$$
12 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
13 trap '(exit $?); exit' 1 2 13 15
14
15 framework_failure=0
16 mkdir $tmp || framework_failure=1
17 cd $tmp || framework_failure=1
18
19 touch src || framework_failure=1
20 touch dest || framework_failure=1
21 touch dest2 || framework_failure=1
22
23 if test $framework_failure = 1; then
24   echo 'failure in testing framework'
25   exit 1
26 fi
27
28 fail=0
29
30 cp -f --link src dest || fail=1
31 cp -f --symbolic-link src dest2 || fail=1
32
33 (exit $fail); exit