.
[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 a different
4 # partitions and DEST is a symlink to SRC.
5
6 : ${MV=mv}
7 : ${RM=rm}
8 : ${LN=ln}
9
10 if test "$VERBOSE" = yes; then
11   set -x
12   $MV --version
13 fi
14
15 . $srcdir/setup
16
17 if test -z "$other_partition_tmpdir"; then
18   exit 77
19 fi
20
21 file="$other_partition_tmpdir/file"
22 symlink=symlink
23
24 framework_failure=0
25 $RM -f $file $symlink || framework_failure=1
26 echo whatever > $file || framework_failure=1
27 $LN -s $file $symlink || framework_failure=1
28
29 if test $framework_failure = 1; then
30   echo 'failure in testing framework'
31   exit 1
32 fi
33
34 # Make sure we get English translations.
35 LANGUAGE=C
36 export LANGUAGE
37 LC_ALL=C
38 export LC_ALL
39 LANG=C
40 export LANG
41
42 # This mv command should exit nonzero.
43 $MV $file $symlink > out 2>&1 && fail=1
44
45 sed \
46    -e "s,$MV:,XXX:," \
47    -e "s,$file,YYY," \
48    -e "s,$symlink,ZZZ," \
49   out > out2
50
51 cat > exp <<\EOF
52 XXX: `YYY' and `ZZZ' are the same file
53 EOF
54
55 cmp out2 exp || fail=1
56
57 $RM -fr out out2 exp $file $symlink $other_partition_tmpdir
58
59 exit $fail