2 # exercise another small part of remove.c
4 if test "$VERBOSE" = yes; then
9 . $srcdir/../envvar-check
10 . $srcdir/../lang-default
11 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
14 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
15 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
16 trap '(exit $?); exit' 1 2 13 15
19 mkdir -p $tmp || framework_failure=1
20 cd $tmp || framework_failure=1
21 mkdir -p z || framework_failure=1
22 cd z || framework_failure=1
23 touch empty empty-u || framework_failure=1
27 mkdir d du || framework_failure=1
28 chmod u-w fu du empty-u || framework_failure=1
31 if test $framework_failure = 1; then
32 echo "$0: failure in testing framework" 1>&2
50 # Both of these should fail.
51 rm -ir z < in > out 2>&1 || fail=1
53 # Given input like `rm: ...? rm: ...? ' (no trailing newline),
54 # the `head...' part of the pipeline below removes the trailing space, so
55 # that sed doesn't have to deal with a line lacking a terminating newline.
56 # This avoids a bug whereby some vendor-provided (Tru64) versions of sed
57 # would mistakenly tack a newline onto the end of the output.
58 tr '?' '\n' < out | head --bytes=-1 | sed 's/^ //' |sort > o2
61 sort <<EOF > exp || fail=1
62 rm: descend into directory \`z'
63 rm: remove regular empty file \`z/empty'
64 rm: remove write-protected regular file \`z/fu'
65 rm: remove write-protected regular empty file \`z/empty-u'
66 rm: remove symbolic link \`z/slink'
67 rm: remove symbolic link \`z/slinkdot'
68 rm: remove directory \`z/d'
69 rm: remove write-protected directory \`z/du'
70 rm: remove directory \`z'
74 test $fail = 1 && diff -u out exp 2> /dev/null
78 (exit $fail); exit $fail