2 # Ensure "ls --color" properly colors "normal" text and files.
3 # I.E. that it uses NORMAL to style non file name output and
4 # file names with no associated color (unless FILE is also set).
6 # Copyright (C) 2010-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 . "${srcdir=.}/init.sh"; path_prepend_ ../src
24 # Don't let a different umask perturb the results.
27 # Output time as something constant
28 export TIME_STYLE="+norm"
30 # helper to to strip ls columns up to "norm" time
31 qls() { sed 's/-r.*norm/norm/'; }
33 touch exe || framework_failure
34 chmod u+x exe || framework_failure
35 touch nocolor || framework_failure
37 TCOLORS="no=7:ex=01;32"
39 # Non coloured files inherit NORMAL attributes
40 LS_COLORS=$TCOLORS ls -gGU --color exe nocolor | qls >> out || fail=1
41 LS_COLORS=$TCOLORS ls -xU --color exe nocolor >> out || fail=1
42 LS_COLORS=$TCOLORS ls -gGU --color nocolor exe | qls >> out || fail=1
43 LS_COLORS=$TCOLORS ls -xU --color nocolor exe >> out || fail=1
45 # NORMAL does not override FILE though
46 LS_COLORS=$TCOLORS:fi=1 ls -gGU --color nocolor exe | qls >> out || fail=1
48 # Support uncolored ordinary files that do _not_ inherit from NORMAL.
49 # Note there is a redundant RESET output before a non colored
50 # file in this case which may be removed in future.
51 LS_COLORS=$TCOLORS:fi= ls -gGU --color nocolor exe | qls >> out || fail=1
52 LS_COLORS=$TCOLORS:fi=0 ls -gGU --color nocolor exe | qls >> out || fail=1
54 # A caveat worth noting is that commas (-m), indicator chars (-F)
55 # and the "total" line, do not currently use NORMAL attributes
56 LS_COLORS=$TCOLORS ls -mFU --color nocolor exe >> out || fail=1
58 # Ensure no coloring is done unless enabled
59 LS_COLORS=$TCOLORS ls -gGU nocolor exe | qls >> out || fail=1
61 cat -A out > out.display || framework_failure
62 mv out.display out || framework_failure
64 cat <<\EOF > exp || framework_failure
65 ^[[0m^[[7mnorm ^[[m^[[01;32mexe^[[0m$
66 ^[[7mnorm nocolor^[[0m$
67 ^[[0m^[[7m^[[m^[[01;32mexe^[[0m ^[[7mnocolor^[[0m$
68 ^[[0m^[[7mnorm nocolor^[[0m$
69 ^[[7mnorm ^[[m^[[01;32mexe^[[0m$
70 ^[[0m^[[7mnocolor^[[0m ^[[7m^[[m^[[01;32mexe^[[0m$
71 ^[[0m^[[7mnorm ^[[m^[[1mnocolor^[[0m$
72 ^[[7mnorm ^[[m^[[01;32mexe^[[0m$
73 ^[[0m^[[7mnorm ^[[m^[[mnocolor^[[0m$
74 ^[[7mnorm ^[[m^[[01;32mexe^[[0m$
75 ^[[0m^[[7mnorm ^[[m^[[0mnocolor^[[0m$
76 ^[[7mnorm ^[[m^[[01;32mexe^[[0m$
77 ^[[0m^[[7mnocolor^[[0m, ^[[7m^[[m^[[01;32mexe^[[0m*$
82 compare out exp || fail=1