2002-05-21 22:58:48 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
# exercise another small part of remove.c
|
|
|
|
|
|
2026-01-01 10:56:16 -08:00
|
|
|
# Copyright (C) 2002-2026 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
|
2017-09-19 01:13:23 -07:00
|
|
|
# along with this program. If not, see <https://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-05-21 22:58:48 +00:00
|
|
|
|
2011-08-04 20:52:31 +02:00
|
|
|
mkdir -p z || framework_failure_
|
|
|
|
|
cd z || framework_failure_
|
|
|
|
|
touch empty empty-u || framework_failure_
|
2002-05-22 09:49:14 +00:00
|
|
|
echo not-empty > fu
|
|
|
|
|
ln -s empty-f slink
|
2002-05-21 22:58:48 +00:00
|
|
|
ln -s . slinkdot
|
2011-08-04 20:52:31 +02:00
|
|
|
mkdir d du || framework_failure_
|
|
|
|
|
chmod u-w fu du empty-u || framework_failure_
|
2002-05-21 22:58:48 +00:00
|
|
|
cd ..
|
|
|
|
|
|
|
|
|
|
|
2017-08-28 21:51:37 -07:00
|
|
|
cat <<EOF > in || framework_failure_
|
2002-05-21 22:58:48 +00:00
|
|
|
y
|
|
|
|
|
y
|
|
|
|
|
y
|
|
|
|
|
y
|
|
|
|
|
y
|
|
|
|
|
y
|
|
|
|
|
y
|
|
|
|
|
y
|
2002-05-22 09:49:14 +00:00
|
|
|
y
|
2002-05-21 22:58:48 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
# Both of these should fail.
|
|
|
|
|
rm -ir z < 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/^ //' |sort > o2
|
2017-08-28 21:51:37 -07:00
|
|
|
mv o2 out || framework_failure_
|
2002-05-21 22:58:48 +00:00
|
|
|
|
2017-08-28 21:51:37 -07:00
|
|
|
sort <<EOF > exp || framework_failure_
|
2012-01-07 17:43:50 +01:00
|
|
|
rm: descend into directory 'z'
|
|
|
|
|
rm: remove regular empty file 'z/empty'
|
|
|
|
|
rm: remove write-protected regular file 'z/fu'
|
|
|
|
|
rm: remove write-protected regular empty file 'z/empty-u'
|
|
|
|
|
rm: remove symbolic link 'z/slink'
|
|
|
|
|
rm: remove symbolic link 'z/slinkdot'
|
|
|
|
|
rm: remove directory 'z/d'
|
|
|
|
|
rm: remove write-protected directory 'z/du'
|
|
|
|
|
rm: remove directory 'z'
|
2002-05-21 22:58:48 +00:00
|
|
|
EOF
|
|
|
|
|
|
2011-11-22 10:08:04 +01:00
|
|
|
compare exp out || fail=1
|
2002-05-21 22:58:48 +00:00
|
|
|
|
|
|
|
|
test -d z && fail=1
|
|
|
|
|
|
2008-09-07 10:31:27 +02:00
|
|
|
Exit $fail
|