maint: sync help2man to latest version
[coreutils.git] / tests / rm / interactive-always.sh
blobbf15a984b330f09bfdaaf4e64743fcc3f16200d1
1 #!/bin/sh
2 # Test the --interactive[=WHEN] changes added to coreutils 6.0
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
20 print_ver_ rm
22 touch file1-1 file1-2 file2-1 file2-2 file3-1 file3-2 file4-1 file4-2 \
23 || framework_failure_
24 # If asked, answer no to first question, then yes to second.
25 echo 'n
26 y' > in || framework_failure_
27 rm -f out err || framework_failure_
30 # The prompt has a trailing space, and no newline, so an extra
31 # 'echo .' is inserted after each rm to make it obvious what was asked.
33 echo 'no WHEN' > err || framework_failure_
34 rm -R --interactive file1-* < in >> out 2>> err || fail=1
35 echo . >> err || framework_failure_
36 test -f file1-1 || fail=1
37 test -f file1-2 && fail=1
39 echo 'WHEN=never' >> err || framework_failure_
40 rm -R --interactive=never file2-* < in >> out 2>> err || fail=1
41 echo . >> err || framework_failure_
42 test -f file2-1 && fail=1
43 test -f file2-2 && fail=1
45 echo 'WHEN=once' >> err || framework_failure_
46 rm -R --interactive=once file3-* < in >> out 2>> err || fail=1
47 echo . >> err || framework_failure_
48 test -f file3-1 || fail=1
49 test -f file3-2 || fail=1
51 echo 'WHEN=always' >> err || framework_failure_
52 rm -R --interactive=always file4-* < in >> out 2>> err || fail=1
53 echo . >> err || framework_failure_
54 test -f file4-1 || fail=1
55 test -f file4-2 && fail=1
57 echo '-f overrides --interactive' >> err || framework_failure_
58 rm -R --interactive=once -f file1-* < in >> out 2>> err || fail=1
59 echo . >> err || framework_failure_
60 test -f file1-1 && fail=1
62 echo '--interactive overrides -f' >> err || framework_failure_
63 rm -R -f --interactive=once file4-* < in >> out 2>> err || fail=1
64 echo . >> err || framework_failure_
65 test -f file4-1 || fail=1
67 cat <<\EOF > experr.t || framework_failure_
68 no WHEN
69 @remove_empty 'file1-1'? @remove_empty 'file1-2'? .
70 WHEN=never
72 WHEN=once
73 rm: remove 2 arguments recursively? .
74 WHEN=always
75 @remove_empty 'file4-1'? @remove_empty 'file4-2'? .
76 -f overrides --interactive
78 --interactive overrides -f
79 rm: remove 1 argument recursively? .
80 EOF
81 sed 's/@remove_empty/rm: remove regular empty file/g' < experr.t > experr ||
82 framework_failure_
84 compare /dev/null out || fail=1
85 compare experr err || fail=1
87 Exit $fail