2002-06-01 08:41:31 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
# a basic test of rm -ri
|
|
|
|
|
|
2014-01-02 20:52:55 +01:00
|
|
|
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
|
2006-08-17 19:58:17 +00:00
|
|
|
|
2007-07-23 14:35:58 +02:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2006-08-17 19:58:17 +00:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-23 14:35:58 +02:00
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
2006-08-17 19:58:17 +00:00
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-07-23 14:35:58 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-08-17 19:58:17 +00:00
|
|
|
|
2012-09-02 21:55:12 +02:00
|
|
|
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
|
2010-11-17 21:35:31 +01:00
|
|
|
print_ver_ rm
|
2007-09-12 14:52:26 +02:00
|
|
|
skip_if_root_
|
2002-06-01 08:41:31 +00:00
|
|
|
|
2011-08-04 20:52:31 +02:00
|
|
|
mkdir -p d/e || framework_failure_
|
|
|
|
|
cat <<EOF > in || framework_failure_
|
2002-06-01 08:41:31 +00:00
|
|
|
y
|
|
|
|
|
y
|
|
|
|
|
y
|
|
|
|
|
EOF
|
|
|
|
|
|
2011-08-04 20:52:31 +02:00
|
|
|
cat <<\EOF > exp || framework_failure_
|
2012-01-07 17:47:58 +01:00
|
|
|
rm: descend into directory 'd'
|
|
|
|
|
rm: remove directory 'd/e'
|
|
|
|
|
rm: remove directory 'd'
|
2002-06-01 08:41:31 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rm -ir d < in > out 2>&1 || fail=1
|
2004-02-08 10:00:38 +00:00
|
|
|
|
2012-01-07 17:47:58 +01:00
|
|
|
# Given input like 'rm: ...? rm: ...? ' (no trailing newline),
|
|
|
|
|
# the 'head...' part of the pipeline below removes the trailing space, so
|
2004-02-08 10:00:38 +00:00
|
|
|
# that sed doesn't have to deal with a line lacking a terminating newline.
|
|
|
|
|
# This avoids a bug whereby some vendor-provided (Tru64) versions of sed
|
|
|
|
|
# would mistakenly tack a newline onto the end of the output.
|
|
|
|
|
tr '?' '\n' < out | head --bytes=-1 | sed 's/^ //' > o2
|
2002-06-01 08:41:31 +00:00
|
|
|
mv o2 out
|
|
|
|
|
|
|
|
|
|
# Make sure it's been removed.
|
|
|
|
|
test -d d && fail=1
|
|
|
|
|
|
2011-11-22 10:08:04 +01:00
|
|
|
compare exp out || fail=1
|
2002-06-01 08:41:31 +00:00
|
|
|
|
2008-09-07 10:31:27 +02:00
|
|
|
Exit $fail
|