rm: update gnulib to get an fts fix for Cygwin+NWFS/NcFsd file systems
[coreutils/ericb.git] / tests / mv / dup-source
blob0bbe36aedbc5d1bea64f6c5e1767bd3b14fff583
1 #!/bin/sh
2 # Ensure that cp merely warns when a non-directory source file is
3 # listed on the command line more than once. fileutils-4.1.1
4 # made this fail: cp a a d/
5 # Ensure that mv fails with a similar command.
7 # Copyright (C) 2001-2002, 2004, 2006-2011 Free Software Foundation, Inc.
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 . "${srcdir=.}/init.sh"; path_prepend_ ../src
23 print_ver_ cp mv
25 skip_if_root_
27 for i in cp; do
29 # cp may not fail in this case.
31 rm -fr a d; touch a; mkdir d
32 $i a a d/ 2> out || fail=1
33 rm -fr a d; touch a; mkdir d
34 $i ./a a d/ 2>> out || fail=1
36 # cp succeeds with --backup=numbered.
37 rm -fr a d; touch a; mkdir d
38 $i --backup=numbered a a d/ 2>> out || fail=1
40 # But not with plain `--backup'
41 rm -fr a d; touch a; mkdir d
42 $i --backup a a d/ 2>> out && fail=1
43 cat <<EOF > exp
44 $i: warning: source file \`a' specified more than once
45 $i: warning: source file \`a' specified more than once
46 $i: will not overwrite just-created \`d/a' with \`a'
47 EOF
48 compare out exp || fail=1
49 done
51 for i in mv; do
52 # But mv *does* fail in this case (it has to).
54 rm -fr a d; touch a; mkdir d
55 $i a a d/ 2> out && fail=1
56 rm -fr a d; touch a; mkdir d
57 $i ./a a d/ 2>> out && fail=1
58 cat <<EOF > exp
59 $i: cannot stat \`a': No such file or directory
60 $i: cannot stat \`a': No such file or directory
61 EOF
62 compare out exp || fail=1
63 done
65 Exit $fail