Update all copyright notices to use the newer form.
[platform/upstream/coreutils.git] / tests / mv / backup-dir
1 #!/bin/sh
2 # Ensure "mv --verbose --backup" works the same for dirs and non-dirs.
3
4 # Copyright (C) 2006 Free Software Foundation, Inc.
5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 if test "$VERBOSE" = yes; then
20   set -x
21   mv --version
22 fi
23
24 . $srcdir/../envvar-check
25 . $srcdir/../lang-default
26
27 pwd=`pwd`
28 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
29 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
30 trap '(exit $?); exit $?' 1 2 13 15
31
32 framework_failure=0
33 mkdir -p $tmp || framework_failure=1
34 cd $tmp || framework_failure=1
35
36 mkdir A B || framework_failure=1
37 touch X Y || framework_failure=1
38
39 if test $framework_failure = 1; then
40   echo "$0: failure in testing framework" 1>&2
41   (exit 1); exit 1
42 fi
43
44 fail=0
45
46 # Before coreutils-6.2, the " (backup: `B.~1~')" suffix was not printed.
47 mv --verbose --backup=numbered -T A B > out || fail=1
48 cat <<\EOF > exp || fail=1
49 `A' -> `B' (backup: `B.~1~')
50 EOF
51
52 cmp out exp || fail=1
53 test $fail = 1 && diff out exp 2> /dev/null
54
55 (exit $fail); exit $fail