2002-06-01 16:41:31 +08:00
|
|
|
#!/bin/sh
|
|
|
|
# a basic test of rm -ri
|
|
|
|
|
2024-01-01 21:22:42 +08:00
|
|
|
# Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
2006-08-18 03:58:17 +08:00
|
|
|
|
2007-07-23 20:35:58 +08:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2006-08-18 03:58:17 +08:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-23 20:35:58 +08:00
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
2006-08-18 03:58:17 +08: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
|
2017-09-19 16:13:23 +08:00
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2006-08-18 03:58:17 +08:00
|
|
|
|
2012-09-03 03:55:12 +08:00
|
|
|
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
|
2010-11-18 04:35:31 +08:00
|
|
|
print_ver_ rm
|
2007-09-12 20:52:26 +08:00
|
|
|
skip_if_root_
|
2002-06-01 16:41:31 +08:00
|
|
|
|
2011-08-05 02:52:31 +08:00
|
|
|
mkdir -p d/e || framework_failure_
|
|
|
|
cat <<EOF > in || framework_failure_
|
2002-06-01 16:41:31 +08:00
|
|
|
y
|
|
|
|
y
|
|
|
|
y
|
|
|
|
EOF
|
|
|
|
|
2011-08-05 02:52:31 +08:00
|
|
|
cat <<\EOF > exp || framework_failure_
|
2012-01-08 00:47:58 +08:00
|
|
|
rm: descend into directory 'd'
|
|
|
|
rm: remove directory 'd/e'
|
|
|
|
rm: remove directory 'd'
|
2002-06-01 16:41:31 +08:00
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
rm -ir d < in > out 2>&1 || fail=1
|
2004-02-08 18:00:38 +08:00
|
|
|
|
2012-01-08 00:47:58 +08:00
|
|
|
# Given input like 'rm: ...? rm: ...? ' (no trailing newline),
|
|
|
|
# the 'head...' part of the pipeline below removes the trailing space, so
|
2004-02-08 18:00:38 +08: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 16:41:31 +08:00
|
|
|
mv o2 out
|
|
|
|
|
|
|
|
# Make sure it's been removed.
|
|
|
|
test -d d && fail=1
|
|
|
|
|
2011-11-22 17:08:04 +08:00
|
|
|
compare exp out || fail=1
|
2002-06-01 16:41:31 +08:00
|
|
|
|
2008-09-07 16:31:27 +08:00
|
|
|
Exit $fail
|