db63e73833646d8582e7c7ec0ef437222e68cb8b
[platform/upstream/coreutils.git] / tests / mv / backup-is-src
1 #!/bin/sh
2 # Force mv to use the copying code.
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   mv --version
7 fi
8
9 . $srcdir/setup
10 . $srcdir/../envvar-check
11
12 if test -z "$other_partition_tmpdir"; then
13   exit 77
14 fi
15
16 a="$other_partition_tmpdir/a"
17 a2="$other_partition_tmpdir/a~"
18
19 framework_failure=0
20 rm -f $a $a2 || framework_failure=1
21 echo a > $a || framework_failure=1
22 echo a2 > $a2 || framework_failure=1
23
24 if test $framework_failure = 1; then
25   echo 'failure in testing framework'
26   exit 1
27 fi
28
29 # Make sure we get English translations.
30 . $srcdir/../lang-default
31
32 # This mv command should exit nonzero.
33 mv --b=simple $a2 $a > out 2>&1 && fail=1
34
35 sed \
36    -e "s,mv:,XXX:," \
37    -e "s,$a,YYY," \
38    -e "s,$a2,ZZZ," \
39   out > out2
40
41 cat > exp <<\EOF
42 XXX: backing up `YYY' would destroy source;  `ZZZ' not moved
43 EOF
44
45 cmp out2 exp || fail=1
46
47 rm -fr out out2 exp $a $a2 $other_partition_tmpdir
48
49 exit $fail