0ff12ea9316d0ff3045d1f6fff6843a139c4035f
[platform/upstream/coreutils.git] / tests / du / deref
1 #!/bin/sh
2 # prior to coreutils-4.5.3, du -D didn't work in some cases
3 # Based on an example from Andreas Schwab and/or Michal Svec.
4
5 if test "$VERBOSE" = yes; then
6   set -x
7   du --version
8 fi
9
10 pwd=`pwd`
11 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
12 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
13 trap '(exit $?); exit $?' 1 2 13 15
14
15 framework_failure=0
16 mkdir -p $tmp || framework_failure=1
17 cd $tmp || framework_failure=1
18 mkdir -p a/sub || framework_failure=1
19 ln -s a/sub slink || framework_failure=1
20 touch b || 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 used to fail with the following diagnostic:
30 # du: `b': No such file or directory
31 du -sD slink b > /dev/null 2>&1 || fail=1
32
33 (exit $fail); exit $fail