2293b2d65e9e283e5cb22c80f376bde75916e3a2
[platform/upstream/coreutils.git] / tests / mv / force
1 #!/bin/sh
2 # move a file onto itself
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   mv --version
7 fi
8
9 ff=mvforce
10 ff2=mvforce2
11
12 framework_failure=0
13 rm -f $ff $ff2 || framework_failure=1
14 echo force-contents > $ff || framework_failure=1
15 ln $ff $ff2 || framework_failure=1
16
17 if test $framework_failure = 1; then
18   echo 'failure in testing framework'
19   exit 1
20 fi
21
22 # Make sure we get English translations.
23 . $srcdir/../lang-default
24
25 # This mv command should exit nonzero.
26 mv $ff $ff > out 2>&1 && fail=1
27
28 cat > exp <<EOF
29 mv: \`$ff' and \`$ff' are the same file
30 EOF
31
32 cmp out exp || fail=1
33 test `cat $ff` = force-contents || fail=1
34
35 # This should succeed, even though the source and destination
36 # device and inodes are the same.
37 mv $ff $ff2 || fail=1
38
39 rm -fr out exp $ff $ff2
40
41 exit $fail