6aaf35d86e95b4d950f2efce1585d92a544ea327
[platform/upstream/coreutils.git] / tests / mv / into-self-4
1 #!/bin/sh
2 # confirm that `mv symlink symlink' doesn't remove symlink
3 # Based on an example from David Luyer.
4
5 if test "$VERBOSE" = yes; then
6   set -x
7   mv --version
8 fi
9
10 . $srcdir/../envvar-check
11
12 pwd=`pwd`
13 tmp=mv-slink2.$$
14 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
15 trap '(exit $?); exit' 1 2 13 15
16
17 framework_failure=0
18 mkdir $tmp || framework_failure=1
19 cd $tmp || framework_failure=1
20 touch file || framework_failure=1
21 ln -s file s || framework_failure=1
22
23 if test $framework_failure = 1; then
24   echo 'failure in testing framework' 1>&2
25   (exit 1); exit 1
26 fi
27
28 fail=0
29
30 # This must fail.
31 mv s s 2> /dev/null && fail=1
32
33 # But the symlink, s, must not be removed.
34 # Before 4.0.36, `s' would have been removed.
35 test -f s || fail=1
36
37 (exit $fail); exit $fail