Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / rm / r-4
1 #!/bin/sh
2 # Try to remove '.' and '..' recursively.
3
4 # Copyright (C) 2006 Free Software Foundation, Inc.
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21
22 if test "$VERBOSE" = yes; then
23   rm --version
24   set -x
25 fi
26
27 pwd=`pwd`
28 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
29 trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
30 trap '(exit $?); exit' 1 2 13 15
31
32 framework_failure=0
33 mkdir -p $tmp || framework_failure=1
34 cd $tmp || framework_failure=1
35
36 touch a || framework_failure=1
37 cd "$pwd" || framework_failure=1
38
39 if test $framework_failure = 1; then
40   echo 'failure in testing framework'
41   (exit 1); exit 1
42 fi
43
44 fail=0
45 rm -fr $tmp/. 2>/dev/null && fail=1
46 rm -fr $tmp/./ 2>/dev/null && fail=1
47 rm -fr $tmp/.//// 2>/dev/null && fail=1
48 rm -fr $tmp/.. 2>/dev/null && fail=1
49 rm -fr $tmp/../ 2>/dev/null && fail=1
50
51 # This test is too dangerous -- if there's a bug you're wiped out!
52 # rm -fr / 2>/dev/null && fail=1
53
54 test -f $tmp/a || fail=1
55
56 (exit $fail); exit $fail