Add/fix copyright notices and adjust to latest GNU FDL.
[platform/upstream/coreutils.git] / tests / mv / diag
1 #!/bin/sh
2 # make sure we get proper diagnostics: e.g., with --target-dir=d but no args
3
4 # Copyright (C) 2000, 2004 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 2 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, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21 if test "$VERBOSE" = yes; then
22   set -x
23   mv --version
24 fi
25
26 # Make sure we get English translations.
27 . $srcdir/../lang-default
28
29 pwd=`pwd`
30 tmp=diag-$$
31 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
32 trap 'exit $?' 1 2 13 15
33
34 framework_failure=0
35 mkdir $tmp || framework_failure=1
36 cd $tmp || framework_failure=1
37
38 touch f1 || framework_failure=1
39 touch f2 || framework_failure=1
40 touch d || framework_failure=1
41
42 if test $framework_failure = 1; then
43   echo 'failure in testing framework'
44   exit 1
45 fi
46
47 # These mv commands should all exit nonzero.
48
49 # Too few args.  This first one did fail, but with an incorrect diagnostic
50 # until fileutils-4.0u.
51 mv --target=. >> out 2>&1 && fail=1
52 mv no-file >> out 2>&1 && fail=1
53
54 # Target is not a directory.
55 mv f1 f2 f1 >> out 2>&1 && fail=1
56 mv --target=f2 f1 >> out 2>&1 && fail=1
57
58 cat > exp <<\EOF
59 mv: missing file operand
60 Try `mv --help' for more information.
61 mv: missing destination file operand after `no-file'
62 Try `mv --help' for more information.
63 mv: target `f1' is not a directory
64 mv: target `f2' is not a directory
65 EOF
66
67 cmp out exp || fail=1
68
69 (exit $fail)
70 exit $fail