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-2013 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=.}/tests/init.sh"; path_prepend_ .
/src
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
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'
48 compare exp out || fail
=1
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
59 $i: cannot stat 'a': No such file or directory
60 $i: cannot stat 'a': No such file or directory
62 compare exp out || fail
=1