527393e565fc60d5d9e20c2a0a60f93a44312e09
[platform/upstream/coreutils.git] / tests / ls / follow-slink
1 #!/bin/sh
2 # make sure ls -L always follows symlinks
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   ls --version
7 fi
8
9 pwd=`pwd`
10 tmp=follow-sl.$$
11 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
12 trap '(exit $?); exit' 1 2 13 15
13
14 framework_failure=0
15 mkdir $tmp || framework_failure=1
16 cd $tmp || framework_failure=1
17
18 # Isolate output files from directory being listed
19 mkdir dir || framework_failure=1
20 cd dir || framework_failure=1
21 ln -s link link || framework_failure=1
22
23 # Make sure the symlink was created.
24 # `ln -s link link' succeeds, but creates no file on
25 # systems running some DJGPP-2.03 libc.
26 ls -F link > /dev/null || framework_failure=1
27
28 if test $framework_failure = 1; then
29   echo 'failure in testing framework'
30   (exit 1); exit 1
31 fi
32
33 fail=0
34
35 # When explicitly listing a broken link, the command must fail.
36 ls -L link 2> /dev/null && fail=1
37
38 # When encountering a broken link implicitly, Solaris 9 and OpenBSD 3.4
39 # list the link, provided no further information about the link needed
40 # to be printed.  Since POSIX does not specify one way or the other, we
41 # opt for compatibility (this was broken in 5.3.0 through 5.94).
42 ls -L > ../out || fail=1
43
44 cd .. || fail=1
45
46 cat <<\EOF > exp
47 link
48 EOF
49
50 cmp out exp || fail=1
51 test $fail = 1 && diff out exp 2> /dev/null
52
53 (exit $fail); exit $fail