57733c8fd11f3ef6bd11b667709a7ca039f4eedb
[platform/upstream/coreutils.git] / tests / rm / i-no-r
1 #!/bin/sh
2 # Since the rewrite for fileutils-4.1.9, `rm -i DIR' would mistakenly
3 # recurse into directory DIR.  rm -i (without -r) must fail in that case.
4 # Fixed in coreutils-4.5.2.
5
6 if test "$VERBOSE" = yes; then
7   set -x
8   rm --version
9 fi
10
11 pwd=`pwd`
12 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
13 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
14 trap '(exit $?); exit $?' 1 2 13 15
15
16 framework_failure=0
17 mkdir -p $tmp || framework_failure=1
18 cd $tmp || framework_failure=1
19 mkdir dir || framework_failure=1
20 echo y > y || framework_failure=1
21
22 if test $framework_failure = 1; then
23   echo "$0: failure in testing framework" 1>&2
24   (exit 1); exit 1
25 fi
26
27 fail=0
28
29 # This must fail.
30 rm -i dir < y > /dev/null 2>&1 && fail=1
31
32 # The directory must remain.
33 test -d dir || fail=1
34
35 (exit $fail); exit $fail