summaryrefslogtreecommitdiff
path: root/tests/rm/r-2
blob: 2bba1f5c6b6280125399d473b5ff69e0b09a1ca4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh

: ${RM=rm}
test=r-2

: ${TMPDIR=.}

if test "$VERBOSE" = yes; then
  $RM --version
  set -x
fi

tmp=$TMPDIR/t-rm.$$

mkdir $tmp $tmp/a $tmp/a/b
> $tmp/a/f
> $tmp/a/b/g

LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL

# FIXME: if this fails, it's a framework failure
cat <<EOF | sort > $tmp/$test.E
removing all entries of directory $tmp/a
removing all entries of directory $tmp/a/b
removing $tmp/a/b/g
removing the directory itself: $tmp/a/b
removing $tmp/a/f
removing the directory itself: $tmp/a
EOF

# Note that both the expected output (above) and the actual output lines
# are sorted, because directory entries may be processed in arbitrary order.
fail=0
$RM --verbose -r $tmp/a | sort > $tmp/$test.O || fail=1

if test -d $tmp/a; then
  fail=1
fi

# Compare expected and actual output.
cmp $tmp/$test.E $tmp/$test.O || fail=1

rm -rf $tmp

exit $fail