Adapt to reflect this change in behavior.
[platform/upstream/coreutils.git] / tests / mv / into-self-2
1 #!/bin/sh
2 # Force mv to use the copying code.
3 # Consider the case where SRC and DEST are on different
4 # partitions and DEST is a symlink to SRC.
5
6 if test "$VERBOSE" = yes; then
7   set -x
8   mv --version
9 fi
10
11 . $srcdir/setup
12
13 if test -z "$other_partition_tmpdir"; then
14   exit 77
15 fi
16
17 file="$other_partition_tmpdir/file"
18 symlink=symlink
19
20 fail=0
21
22 trap 'rm -fr out out2 exp $file $symlink $other_partition_tmpdir; exit $fail' \
23   0 1 2 3 15
24
25 framework_failure=0
26 rm -f $file $symlink || framework_failure=1
27 echo whatever > $file || framework_failure=1
28 ln -s $file $symlink || framework_failure=1
29
30 if test $framework_failure = 1; then
31   echo 'failure in testing framework'
32   exit 1
33 fi
34
35 # Make sure we get English translations.
36 LANGUAGE=C
37 export LANGUAGE
38 LC_ALL=C
39 export LC_ALL
40 LANG=C
41 export LANG
42
43 unset VERSION_CONTROL
44
45 if test "${VERSION_CONTROL+set}" = set; then
46   echo '$0: the VERSION_CONTROL envvar is set --' \
47     ' unset it and rerun this test' >&2
48   exit 1
49 fi
50
51 # This mv command should exit nonzero.
52 mv $symlink $file > out 2>&1 && fail=1
53
54 # This should succeed.
55 mv $file $symlink || fail=1
56
57 sed \
58    -e "s,mv:,XXX:," \
59    -e "s,$file,YYY," \
60    -e "s,$symlink,ZZZ," \
61   out > out2
62
63 cat > exp <<\EOF
64 XXX: `ZZZ' and `YYY' are the same file
65 EOF
66 #'
67
68 cmp out2 exp || fail=1
69 test $fail = 1 && diff out2 exp 2> /dev/null
70
71 exit $fail