doc: clarify which ls color attributes don't apply to dirs
[coreutils.git] / tests / ls / classify.sh
blob557c1c0568a722b819848f534268d4713e9b6017
1 #!/bin/sh
2 # Test --classify processing
4 # Copyright (C) 2020-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ ls
22 mkdir testdir || framework_failure_
23 cd testdir || framework_failure_
24 mkdir dir || framework_failure_
25 touch regular executable || framework_failure_
26 chmod a+x executable || framework_failure_
27 ln -s regular slink-reg || framework_failure_
28 ln -s dir slink-dir || framework_failure_
29 ln -s nowhere slink-dangle || framework_failure_
30 mknod block b 20 20 2> /dev/null && block="block
32 mknod char c 10 10 2> /dev/null && char="char
34 mkfifo_or_skip_ fifo
35 cd ..
37 cat <<EOF > exp
38 $block${char}dir/
39 executable*
40 fifo|
41 regular
42 slink-dangle@
43 slink-dir@
44 slink-reg@
45 EOF
46 sed 's/[*/@|]//' exp > exp2 || framework_failure_
48 ls --classify testdir > out || fail=1
49 ls --classify=always testdir > out2 || fail=1
50 ls --classify=auto testdir > out3 || fail=1
51 ls --classify=never testdir > out4 || fail=1
53 compare exp out || fail=1
55 compare exp out2 || fail=1
57 compare exp2 out3 || fail=1
59 compare exp2 out4 || fail=1
61 returns_ 1 ls --classify=invalid || fail=1
63 Exit $fail