tests: avoid a race in tail --retry testing
[coreutils.git] / tests / mv / mv-n.sh
blobd829c63bc8731c54ff4902a3bf636288892fe5bc
1 #!/bin/sh
2 # Test whether mv -n works as documented (not overwrite target).
4 # Copyright (C) 2006-2013 Free Software Foundation, Inc.
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.
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.
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/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ mv
23 # test miscellaneous combinations of -f -i -n parameters
24 touch a b || framework_failure_
25 echo "'a' -> 'b'" > out_move
26 > out_empty
28 # ask for overwrite, answer no
29 touch a b || framework_failure_
30 echo n | mv -vi a b 2>/dev/null > out1 || fail=1
31 compare out1 out_empty || fail=1
33 # ask for overwrite, answer yes
34 touch a b || framework_failure_
35 echo y | mv -vi a b 2>/dev/null > out2 || fail=1
36 compare out2 out_move || fail=1
38 # -n wins (as the last option)
39 touch a b || framework_failure_
40 echo y | mv -vin a b 2>/dev/null > out3 || fail=1
41 compare out3 out_empty || fail=1
43 # -n wins (as the last option)
44 touch a b || framework_failure_
45 echo y | mv -vfn a b 2>/dev/null > out4 || fail=1
46 compare out4 out_empty || fail=1
48 # -n wins (as the last option)
49 touch a b || framework_failure_
50 echo y | mv -vifn a b 2>/dev/null > out5 || fail=1
51 compare out5 out_empty || fail=1
53 # options --backup and --no-clobber are mutually exclusive
54 touch a || framework_failure_
55 mv -bn a b 2>/dev/null && fail=1
57 Exit $fail