*** empty log message ***
[coreutils.git] / tests / mv / into-self
blobd6120aed763e64847ec8fe7e2222300cc338d73d
1 #! /bin/sh
2 # Demonstrate how mv fails when it tries to move a directory into itself.
4 if test "$VERBOSE" = yes; then
5 set -x
6 mv --version
7 fi
9 dir=toself-dir
10 file=toself-file
12 test_failure=0
14 rm -rf $dir $file || test_failure=1
15 mkdir -p $dir/a/b || test_failure=1
16 touch $file || test_failure=1
18 if test $test_failure = 1; then
19 echo 'failure in testing framework'
20 exit 1
23 fail=0
25 # Make sure we get English translations.
26 . $srcdir/../lang-default
28 # This mv command should fail.
29 mv $dir $file $dir > out 2>&1 && fail=1
31 sed \
32 -e "s,mv:,XXX:," \
33 -e "s,$dir,SRC," \
34 -e "s,$dir/$dir,DEST," \
35 out > out2
37 cat > exp <<\EOF
38 XXX: cannot move `SRC' to a subdirectory of itself, `DEST'
39 EOF
41 cmp out2 exp || fail=1
43 # Make sure the file is gone.
44 test -f $file && fail=1
45 # Make sure the directory is *not* moved.
46 test -d $dir || fail=1
47 test -d $dir/$dir && fail=1
48 # Make sure the file has been moved to the right place.
49 test -f $dir/$file || fail=1
50 rm -rf $dir $file out out2 exp
52 exit $fail