tests: tee: avoid false failure due to fifo usage
[coreutils.git] / tests / ls / color-ext.sh
blobab045ec6a5eb97c280c3783ec0b36d166663c560
1 #!/bin/sh
2 # Ensure "ls --color" properly colors file name extensions.
4 # Copyright (C) 2018-2023 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
21 working_umask_or_skip_
23 touch img1.jpg IMG2.JPG img3.JpG file1.z file2.Z || framework_failure_
24 code_jpg='01;35'
25 code_JPG='01;35;46'
26 code_z='01;31'
27 c0=$(printf '\033[0m')
28 c_jpg=$(printf '\033[%sm' $code_jpg)
29 c_JPG=$(printf '\033[%sm' $code_JPG)
30 c_z=$(printf '\033[%sm' $code_z)
32 # Case insenitive extensions
33 LS_COLORS="*.jpg=$code_jpg:*.Z=$code_z" ls -U1 --color=always \
34 img1.jpg IMG2.JPG file1.z file2.Z > out || fail=1
35 printf "$c0\
36 ${c_jpg}img1.jpg$c0
37 ${c_jpg}IMG2.JPG$c0
38 ${c_z}file1.z$c0
39 ${c_z}file2.Z$c0
40 " > out_ok || framework_failure_
41 compare out out_ok || fail=1
43 # Case sensitive extensions
44 LS_COLORS="*.jpg=$code_jpg:*.JPG=$code_JPG" ls -U1 --color=always \
45 img1.jpg IMG2.JPG img3.JpG > out || fail=1
46 printf "$c0\
47 ${c_jpg}img1.jpg$c0
48 ${c_JPG}IMG2.JPG$c0
49 img3.JpG
50 " > out_ok || framework_failure_
51 compare out out_ok || fail=1
53 # Case insensitive extensions (due to same sequences)
54 LS_COLORS="*.jpg=$code_jpg:*.JPG=$code_jpg" ls -U1 --color=always \
55 img1.jpg IMG2.JPG img3.JpG > out || fail=1
56 printf "$c0\
57 ${c_jpg}img1.jpg$c0
58 ${c_jpg}IMG2.JPG$c0
59 ${c_jpg}img3.JpG$c0
60 " > out_ok || framework_failure_
61 compare out out_ok || fail=1
63 # Case insensitive extensions (due to same sequences (after ignored sequences))
64 # Note later entries in LS_COLORS take precedence.
65 LS_COLORS="*.jpg=$code_jpg:*.jpg=$code_JPG:*.JPG=$code_JPG" \
66 ls -U1 --color=always img1.jpg IMG2.JPG img3.JpG > out || fail=1
67 printf "$c0\
68 ${c_JPG}img1.jpg$c0
69 ${c_JPG}IMG2.JPG$c0
70 ${c_JPG}img3.JpG$c0
71 " > out_ok || framework_failure_
72 compare out out_ok || fail=1
74 # Case sensitive extensions (due to diff sequences (after ignored sequences))
75 # Note later entries in LS_COLORS take precedence.
76 LS_COLORS="*.jpg=$code_JPG:*.jpg=$code_jpg:*.JPG=$code_JPG" \
77 ls -U1 --color=always img1.jpg IMG2.JPG img3.JpG > out || fail=1
78 printf "$c0\
79 ${c_jpg}img1.jpg$c0
80 ${c_JPG}IMG2.JPG$c0
81 img3.JpG
82 " > out_ok || framework_failure_
83 compare out out_ok || fail=1
85 Exit $fail