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-2017 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
27 reset_files
() { rm -fr a b d
; touch a
; mkdir b d
; }
31 # cp may not fail in this case.
33 $i a a d
/ 2> out || fail
=1
35 $i .
/a a d
/ 2>> out || fail
=1
37 # Similarly for directories, but handle
38 # source == dest appropriately.
40 $i -a .
/b b d
/ 2>> out || fail
=1
42 returns_
1 $i -a .
/b b b
/ 2>> out || fail
=1
44 # cp succeeds with --backup=numbered.
46 $i --backup=numbered a a d
/ 2>> out || fail
=1
48 # But not with plain '--backup'
50 returns_
1 $i --backup a a d
/ 2>> out || fail
=1
53 $i: warning: source file 'a' specified more than once
54 $i: warning: source file 'a' specified more than once
55 $i: warning: source directory 'b' specified more than once
56 $i: cannot copy a directory, './b', into itself, 'b/b'
57 $i: warning: source directory 'b' specified more than once
58 $i: will not overwrite just-created 'd/a' with 'a'
60 compare exp out || fail
=1
64 # But mv *does* fail in this case (it has to).
66 returns_
1 $i a a d
/ 2> out || fail
=1
67 returns_
1 test -e a || fail
=1
69 returns_
1 $i .
/a a d
/ 2>> out || fail
=1
70 returns_
1 test -e a || fail
=1
72 # Similarly for directories, also handling
73 # source == dest appropriately.
75 returns_
1 $i .
/b b d
/ 2>> out || fail
=1
76 returns_
1 test -e b || fail
=1
78 returns_
1 $i --verbose .
/b b b
/ 2>> out || fail
=1
82 $i: cannot stat 'a': No such file or directory
83 $i: cannot stat 'a': No such file or directory
84 $i: cannot stat 'b': No such file or directory
85 $i: cannot move './b' to a subdirectory of itself, 'b/b'
86 $i: warning: source directory 'b' specified more than once
88 compare exp out || fail
=1