2 # Test whether mv -n works as documented (not overwrite target).
4 # Copyright (C) 2006-2024 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 <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
23 # test miscellaneous combinations of -f -i -n parameters
24 touch a b || framework_failure_
25 echo "renamed 'a' -> 'b'" > out_move
26 echo "mv: not replacing 'b'" > err_skip || framework_failure_
29 # ask for overwrite, answer no
30 touch a b || framework_failure_
31 echo n | returns_
1 mv -vi a b
2>/dev
/null
> out1 || fail
=1
32 compare out1 out_empty || fail
=1
34 # ask for overwrite, answer yes
35 touch a b || framework_failure_
36 echo y |
mv -vi a b
2>/dev
/null
> out2 || fail
=1
37 compare out2 out_move || fail
=1
39 # -n wins (as the last option)
40 touch a b || framework_failure_
41 echo y | returns_
1 mv -vin a b
2>/dev
/null
> out3 || fail
=1
42 compare out3 out_empty || fail
=1
44 # -n wins (non verbose)
45 touch a b || framework_failure_
46 echo y | returns_
1 mv -in a b
2>err3
> out3 || fail
=1
47 compare out3 out_empty || fail
=1
48 compare err3 err_skip || fail
=1
50 # -n wins (as the last option)
51 touch a b || framework_failure_
52 echo y | returns_
1 mv -vfn a b
2>/dev
/null
> out4 || fail
=1
53 compare out4 out_empty || fail
=1
55 # -n wins (as the last option)
56 touch a b || framework_failure_
57 echo y | returns_
1 mv -vifn a b
2>/dev
/null
> out5 || fail
=1
58 compare out5 out_empty || fail
=1
60 # options --backup and --no-clobber are mutually exclusive
61 touch a || framework_failure_
62 returns_
1 mv -bn a b
2>/dev
/null || fail
=1