Remove test for the VERSION_CONTROL and/or
[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 . $srcdir/../envvar-check
13
14 if test -z "$other_partition_tmpdir"; then
15   exit 77
16 fi
17
18 file="$other_partition_tmpdir/file"
19 symlink=symlink
20
21 fail=0
22
23 trap 'rm -fr out out2 exp $file $symlink $other_partition_tmpdir; exit $fail' \
24   0 1 2 3 15
25
26 framework_failure=0
27 rm -f $file $symlink || framework_failure=1
28 echo whatever > $file || framework_failure=1
29 ln -s $file $symlink || framework_failure=1
30
31 if test $framework_failure = 1; then
32   echo 'failure in testing framework'
33   exit 1
34 fi
35
36 # Make sure we get English translations.
37 LANGUAGE=C
38 export LANGUAGE
39 LC_ALL=C
40 export LC_ALL
41 LANG=C
42 export LANG
43
44 # This mv command should exit nonzero.
45 mv $symlink $file > out 2>&1 && fail=1
46
47 # This should succeed.
48 mv $file $symlink || fail=1
49
50 sed \
51    -e "s,mv:,XXX:," \
52    -e "s,$file,YYY," \
53    -e "s,$symlink,ZZZ," \
54   out > out2
55
56 cat > exp <<\EOF
57 XXX: `ZZZ' and `YYY' are the same file
58 EOF
59 #'
60
61 cmp out2 exp || fail=1
62 test $fail = 1 && diff out2 exp 2> /dev/null
63
64 exit $fail