2 # move a file onto itself
4 # Copyright (C) 1999-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
25 echo force-contents
> $ff || framework_failure_
26 ln $ff $ff2 || framework_failure_
28 # mv should fail for the same name, or separate hardlinks as in
29 # both cases rename() will do nothing and return success.
30 # One could unlink(src) in the hardlink case, but that would
31 # introduce races with overlapping mv instances removing both hardlinks.
33 for dest
in $ff $ff2; do
34 # This mv command should exit nonzero.
35 mv $ff $dest > out
2>&1 && fail
=1
37 printf "mv: '$ff' and '$dest' are the same file\n" > exp
38 compare exp out || fail
=1
40 test $
(cat $ff) = force-contents || fail
=1