2 # Test the --interactive[=WHEN] changes added to coreutils 6.0
4 # Copyright (C) 2006-2012 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 .
"${srcdir=.}/init.sh"; path_prepend_ ..
/src
24 touch file1-1 file1-2 file2-1 file2-2 file3-1 file3-2 file4-1 file4-2 \
26 # If asked, answer no to first question, then yes to second.
28 y' > $test.I || framework_failure_
29 rm -f out err || framework_failure_
32 # The prompt has a trailing space, and no newline, so an extra
33 # 'echo .' is inserted after each rm to make it obvious what was asked.
35 echo 'no WHEN' > err || fail
=1
36 rm -R --interactive file1-
* < $test.I
>> out
2>> err || fail
=1
37 echo .
>> err || fail
=1
38 test -f file1-1 || fail
=1
39 test -f file1-2
&& fail
=1
41 echo 'WHEN=never' >> err || fail
=1
42 rm -R --interactive=never file2-
* < $test.I
>> out
2>> err || fail
=1
43 echo .
>> err || fail
=1
44 test -f file2-1
&& fail
=1
45 test -f file2-2
&& fail
=1
47 echo 'WHEN=once' >> err || fail
=1
48 rm -R --interactive=once file3-
* < $test.I
>> out
2>> err || fail
=1
49 echo .
>> err || fail
=1
50 test -f file3-1 || fail
=1
51 test -f file3-2 || fail
=1
53 echo 'WHEN=always' >> err || fail
=1
54 rm -R --interactive=always file4-
* < $test.I
>> out
2>> err || fail
=1
55 echo .
>> err || fail
=1
56 test -f file4-1 || fail
=1
57 test -f file4-2
&& fail
=1
59 echo '-f overrides --interactive' >> err || fail
=1
60 rm -R --interactive=once
-f file1-
* < $test.I
>> out
2>> err || fail
=1
61 echo .
>> err || fail
=1
62 test -f file1-1
&& fail
=1
64 echo '--interactive overrides -f' >> err || fail
=1
65 rm -R -f --interactive=once file4-
* < $test.I
>> out
2>> err || fail
=1
66 echo .
>> err || fail
=1
67 test -f file4-1 || fail
=1
69 cat <<\EOF
> expout || fail
=1
71 sed 's/@remove_empty/rm: remove regular empty file/g' <<\EOF
> experr || fail
=1
73 @remove_empty
'file1-1'? @remove_empty
'file1-2'? .
77 rm: remove all arguments recursively? .
79 @remove_empty
'file4-1'? @remove_empty
'file4-2'? .
80 -f overrides
--interactive
82 --interactive overrides
-f
83 rm: remove all arguments recursively? .
86 compare expout out || fail
=1
87 compare experr err || fail
=1