1#!/bin/sh 2# make sure 'mv -i a b' does its job with a positive response 3 4# Copyright (C) 2001-2023 Free Software Foundation, Inc. 5 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. 10 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. 15 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/>. 18 19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 20print_ver_ mv 21 22for i in a b; do 23 echo $i > $i || framework_failure_ 24done 25echo y > y || framework_failure_ 26echo n > n || framework_failure_ 27 28mv -i a b < y >/dev/null 2>&1 || fail=1 29 30# Make sure out contains the prompt. 31case "$(cat b)" in 32 a) ;; 33 *) fail=1 ;; 34esac 35 36# Ensure that mv -i a b works properly with 'n' and 'y' responses, 37# when a and b are hard links to the same file. 38rm -f a b 39echo a > a 40ln a b 41mv -i a b < y 2>err && fail=1 42test -r a || fail=1 43test -r b || fail=1 44printf "mv: 'a' and 'b' are the same file\n" > exp 45compare exp err || fail=1 46 47Exit $fail 48