2 # Test the --interactive[=WHEN] changes added to coreutils 6.0
4 # Copyright (C) 2006, 2007 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 <http://www.gnu.org/licenses/>.
19 test=interactive-always
21 if test "$VERBOSE" = yes; then
26 .
$srcdir/..
/lang-default
27 .
$srcdir/..
/test-lib.sh
29 touch file1-1 file1-2 file2-1 file2-2 file3-1 file3-2 file4-1 file4-2 \
31 # If asked, answer no to first question, then yes to second.
33 y' > $test.I || framework_failure
34 rm -f out err || framework_failure
38 # The prompt has a trailing space, and no newline, so an extra
39 # 'echo .' is inserted after each rm to make it obvious what was asked.
41 echo 'no WHEN' > err || fail
=1
42 rm -R --interactive file1-
* < $test.I
>> out
2>> err || fail
=1
43 echo .
>> err || fail
=1
44 test -f file1-1 || fail
=1
45 test -f file1-2
&& fail
=1
47 echo 'WHEN=never' >> err || fail
=1
48 rm -R --interactive=never file2-
* < $test.I
>> out
2>> err || fail
=1
49 echo .
>> err || fail
=1
50 test -f file2-1
&& fail
=1
51 test -f file2-2
&& fail
=1
53 echo 'WHEN=once' >> err || fail
=1
54 rm -R --interactive=once file3-
* < $test.I
>> out
2>> err || fail
=1
55 echo .
>> err || fail
=1
56 test -f file3-1 || fail
=1
57 test -f file3-2 || fail
=1
59 echo 'WHEN=always' >> err || fail
=1
60 rm -R --interactive=always file4-
* < $test.I
>> out
2>> err || fail
=1
61 echo .
>> err || fail
=1
62 test -f file4-1 || fail
=1
63 test -f file4-2
&& fail
=1
65 echo '-f overrides --interactive' >> err || fail
=1
66 rm -R --interactive=once
-f file1-
* < $test.I
>> out
2>> err || fail
=1
67 echo .
>> err || fail
=1
68 test -f file1-1
&& fail
=1
70 echo '--interactive overrides -f' >> err || fail
=1
71 rm -R -f --interactive=once file4-
* < $test.I
>> out
2>> err || fail
=1
72 echo .
>> err || fail
=1
73 test -f file4-1 || fail
=1
75 cat <<\EOF
> expout || fail
=1
77 cat <<\EOF
> experr || fail
=1
79 rm: remove regular empty
file `file1-1'? rm: remove regular empty file `file1-2
'? .
83 rm: remove all arguments recursively? .
85 rm: remove regular empty file `file4-1'?
rm: remove regular empty
file `file4-2'? .
86 -f overrides --interactive
88 --interactive overrides -f
89 rm: remove all arguments recursively? .
92 compare out expout || fail=1
93 compare err experr || fail=1
95 (exit $fail); exit $fail