Remove suppression-related options.
[coreutils.git] / tests / rm / dir-no-w
blobb0c6a668f514d5ba0ed875a8c90b50de8bcc30d4
1 #!/bin/sh
2 # rm (without -r) must give a diagnostic for any directory.
3 # It must not prompt, even if that directory is unwritable.
5 if test "$VERBOSE" = yes; then
6 set -x
7 rm --version
8 fi
10 . $srcdir/../envvar-check
11 . $srcdir/../lang-default
13 pwd=`pwd`
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
18 framework_failure=0
19 mkdir -p $tmp || framework_failure=1
20 cd $tmp || framework_failure=1
21 mkdir --mode=0500 unwritable-dir || framework_failure=1
23 if test $framework_failure = 1; then
24 echo "$0: failure in testing framework" 1>&2
25 (exit 1); exit 1
28 fail=0
30 # For rm from coreutils-5.0.1, this would prompt.
31 rm --presume-input-tty unwritable-dir < /dev/null > out-t 2>&1 && fail=1
32 cat <<\EOF > exp || fail=1
33 rm: cannot remove `unwritable-dir': Is a directory
34 EOF
36 # When run by a non-privileged user we get this:
37 # rm: cannot remove directory `unwritable-dir': Is a directory
38 # When run by root we get this:
39 # rm: cannot remove `unwritable-dir': Is a directory
40 # Normalize the message.
41 sed 's/remove directory/remove/' out-t > out
42 rm -f out-t
44 cmp out exp || fail=1
45 test $fail = 1 && diff out exp 2> /dev/null
47 (exit $fail); exit $fail