9e2ad79fcfef08dada77abd13463898d53aeaf11
[platform/upstream/coreutils.git] / tests / ls / infloop
1 #!/bin/sh
2 # show that the following no longer makes ls infloop
3 # mkdir loop; cd loop; ln -s ../loop sub; ls -RL
4
5 if test "$VERBOSE" = yes; then
6   set -x
7   ls --version
8 fi
9
10 . $srcdir/../lang-default
11
12 pwd=`pwd`
13 tmp=infloop.$$
14 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
15 trap '(exit $?); exit' 1 2 13 15
16
17 framework_failure=0
18 mkdir $tmp || framework_failure=1
19 cd $tmp || framework_failure=1
20 mkdir loop || framework_failure=1
21 ln -s ../loop loop/sub || framework_failure=1
22
23 if test $framework_failure = 1; then
24   echo 'failure in testing framework' 1>&2
25   (exit 1); exit 1
26 fi
27
28 fail=0
29
30 ls -RL loop 2>err | head -n 7 > out
31 # With an inf-looping ls, out will contain these 7 lines:
32 cat <<EOF > bad
33 loop:
34 sub
35
36 loop/sub:
37 sub
38
39 loop/sub/sub:
40 EOF
41
42 cmp out bad 2>/dev/null && fail=1
43
44 (exit $fail); exit $fail