doc: stat: clarify that %t and %T expand to the file system type
[coreutils/ericb.git] / tests / ls / stat-dtype
blob9b47930f5a85706d3050274a450558ac0a9f81dc
1 #!/bin/sh
2 # Ensure that ls --file-type does not call stat unnecessarily.
3 # Also check for the dtype-related (and fs-type dependent) bug
4 # in coreutils-6.0 that made ls -CF columns misaligned.
6 # Copyright (C) 2006-2011 Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # The trick is to create an un-stat'able symlink and to see if ls
22 # can report its type nonetheless, using dirent.d_type.
24 . "${srcdir=.}/init.sh"; path_prepend_ ../src
25 print_ver_ ls
27 # Skip this test unless "." is on a file system with useful d_type info.
28 # FIXME: This uses "ls -p" to decide whether to test "ls" with other options,
29 # but if ls's d_type code is buggy then "ls -p" might be buggy too.
30 mkdir -p c/d || framework_failure_
31 chmod a-x c || framework_failure_
32 if test "X`ls -p c 2>&1`" != Xd/; then
33 skip_ "'.' is not on a suitable file system for this test"
36 mkdir d || framework_failure_
37 ln -s / d/s || framework_failure_
38 chmod 600 d || framework_failure_
40 mkdir -p e/a2345 e/b || framework_failure_
41 chmod 600 e || framework_failure_
44 ls --file-type d > out || fail=1
45 cat <<\EOF > exp || fail=1
47 EOF
49 compare exp out || fail=1
51 rm -f out exp
52 # Check for the ls -CF misaligned-columns bug:
53 ls -CF e > out || fail=1
55 # coreutils-6.0 would print two spaces after the first slash,
56 # rather than the appropriate TAB.
57 printf 'a2345/\tb/\n' > exp || fail=1
59 compare exp out || fail=1
61 Exit $fail