ls: tune is_colored
[coreutils.git] / tests / mv / part-fail.sh
blob585ed793dee8869e26416bfa00a85038d020780d
1 #!/bin/sh
2 # Make sure we give a sensible diagnostic when a cross-device 'mv'
3 # fails, e.g., because the destination cannot be unlinked.
4 # This is a bit fragile since it relies on the string used
5 # for EPERM: 'permission denied'.
7 # Copyright (C) 2002-2024 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 <https://www.gnu.org/licenses/>.
22 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
23 print_ver_ mv
24 skip_if_root_
25 cleanup_() { t=$other_partition_tmpdir; chmod -R 700 "$t"; rm -rf "$t"; }
26 . "$abs_srcdir/tests/other-fs-tmpdir"
28 touch k "$other_partition_tmpdir/k" || framework_failure_
29 chmod u-w "$other_partition_tmpdir" || framework_failure_
32 mv -f k "$other_partition_tmpdir" 2> out && fail=1
33 printf \
34 "mv: inter-device move failed: '%s' to '%s';"\
35 ' unable to remove target: Permission denied\n' \
36 k "$other_partition_tmpdir/k" >exp
38 # On some (less-compliant) systems, we get EPERM in this case.
39 # Accept either diagnostic.
40 cat <<EOF > exp2
41 mv: cannot move 'k' to '$other_partition_tmpdir/k': Permission denied
42 EOF
44 if cmp out exp >/dev/null 2>&1; then
46 else
47 if cmp out exp2; then
49 else
50 fail=1
53 test $fail = 1 && compare exp out
55 Exit $fail