Port tests/rmdir/ignore away from GNU/Linux.
[coreutils/ericb.git] / tests / rm / interactive-once
blobe09db7c125d6630d125a224896ee1283739d85f0
1 #!/bin/sh
2 # Test the -I option 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-once
21 if test "$VERBOSE" = yes; then
22 set -x
23 rm --version
26 . $srcdir/../lang-default
27 . $srcdir/../test-lib.sh
29 mkdir -p dir1-1 dir2-1 dir2-2 || framework_failure
30 touch file1-1 file2-1 file2-2 file2-3 file3-1 file3-2 file3-3 file3-4 \
31 || framework_failure
32 echo y > $test.Iy || framework_failure
33 echo n > $test.In || framework_failure
34 rm -f out err || framework_failure
36 fail=0
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 'one file, no recursion' > err || fail=1
42 rm -I file1-* < $test.In >> out 2>> err || fail=1
43 echo . >> err || fail=1
44 test -f file1-1 && fail=1
46 echo 'three files, no recursion' >> err || fail=1
47 rm -I file2-* < $test.In >> out 2>> err || fail=1
48 echo . >> err || fail=1
49 test -f file2-1 && fail=1
50 test -f file2-2 && fail=1
51 test -f file2-3 && fail=1
53 echo 'four files, no recursion, answer no' >> err || fail=1
54 rm -I file3-* < $test.In >> out 2>> err || fail=1
55 echo . >> err || fail=1
56 test -f file3-1 || fail=1
57 test -f file3-2 || fail=1
58 test -f file3-3 || fail=1
59 test -f file3-4 || fail=1
61 echo 'four files, no recursion, answer yes' >> err || fail=1
62 rm -I file3-* < $test.Iy >> out 2>> err || fail=1
63 echo . >> err || fail=1
64 test -f file3-1 && fail=1
65 test -f file3-2 && fail=1
66 test -f file3-3 && fail=1
67 test -f file3-4 && fail=1
69 echo 'one file, recursion, answer no' >> err || fail=1
70 rm -I -R dir1-* < $test.In >> out 2>> err || fail=1
71 echo . >> err || fail=1
72 test -d dir1-1 || fail=1
74 echo 'one file, recursion, answer yes' >> err || fail=1
75 rm -I -R dir1-* < $test.Iy >> out 2>> err || fail=1
76 echo . >> err || fail=1
77 test -d dir1-1 && fail=1
79 echo 'multiple files, recursion, answer no' >> err || fail=1
80 rm -I -R dir2-* < $test.In >> out 2>> err || fail=1
81 echo . >> err || fail=1
82 test -d dir2-1 || fail=1
83 test -d dir2-2 || fail=1
85 echo 'multiple files, recursion, answer yes' >> err || fail=1
86 rm -I -R dir2-* < $test.Iy >> out 2>> err || fail=1
87 echo . >> err || fail=1
88 test -d dir2-1 && fail=1
89 test -d dir2-2 && fail=1
91 cat <<\EOF > expout || fail=1
92 EOF
93 cat <<\EOF > experr || fail=1
94 one file, no recursion
96 three files, no recursion
98 four files, no recursion, answer no
99 rm: remove all arguments? .
100 four files, no recursion, answer yes
101 rm: remove all arguments? .
102 one file, recursion, answer no
103 rm: remove all arguments recursively? .
104 one file, recursion, answer yes
105 rm: remove all arguments recursively? .
106 multiple files, recursion, answer no
107 rm: remove all arguments recursively? .
108 multiple files, recursion, answer yes
109 rm: remove all arguments recursively? .
112 compare out expout || fail=1
113 compare err experr || fail=1
115 (exit $fail); exit $fail