7d3ac1e1b32843748fd1feaebbc87266f552fe1c
[platform/upstream/coreutils.git] / tests / rm / i-1
1 #!/bin/sh
2
3 test=i-1
4
5 if test "$VERBOSE" = yes; then
6   set -x
7   rm --version
8 fi
9
10 pwd=`pwd`
11 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
12 trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
13 trap '(exit $?); exit' 1 2 13 15
14
15 test_failure=0
16 mkdir -p $tmp || test_failure=1
17 echo > $tmp/a || test_failure=1
18 test -f $tmp/a || test_failure=1
19
20 if test $test_failure = 1; then
21   echo 'failure in testing framework'
22   exit 1
23 fi
24
25 echo y > $tmp/$test.Iy
26 echo n > $tmp/$test.In
27
28 fail=0
29 rm -i $tmp/a < $tmp/$test.In > /dev/null 2>&1 || fail=1
30 # The file should not have been removed.
31 test -f $tmp/a || fail=1
32
33 rm -i $tmp/a < $tmp/$test.Iy > /dev/null 2>&1 || fail=1
34 # The file should have been removed this time.
35 test -f $tmp/a && fail=1
36
37 rm -rf $tmp
38
39 (exit $fail); exit $fail