From 3491a7702e2d235a255af36e731b84f84da97715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Tue, 13 Oct 2015 12:40:52 +0100 Subject: [PATCH] dircolors: support globbing of TERM entries * src/dircolors.c (dc_parse_stream): Support globbing of TERM entries, to allow entries like "TERM *256color*" for example. * src/dircolors.hin: Reduce the internal list with globbing. * tests/misc/dircolors.pl: New test cases. * NEWS: Mention the improvement. --- NEWS | 3 +++ src/dircolors.c | 3 ++- src/dircolors.hin | 39 +++++---------------------------------- tests/misc/dircolors.pl | 8 ++++++++ 4 files changed, 18 insertions(+), 35 deletions(-) diff --git a/NEWS b/NEWS index 9aec259..80f99f3 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,9 @@ GNU coreutils NEWS -*- outline -*- ** Improvements + dircolors now supports globbing of TERM entries in its database. + For example "TERM *256color*" is now supported. + du no longer stats all mount points at startup, only doing so upon detection of a directory cycle. [issue introduced in coreutils-8.20] diff --git a/src/dircolors.c b/src/dircolors.c index 3a03f1f..d0bd2e4 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -18,6 +18,7 @@ #include #include +#include #include #include "system.h" @@ -293,7 +294,7 @@ dc_parse_stream (FILE *fp, const char *filename) unrecognized = false; if (c_strcasecmp (keywd, "TERM") == 0) { - if (STREQ (arg, term)) + if (fnmatch (arg, term, 0) == 0) state = ST_TERMSURE; else if (state != ST_TERMSURE) state = ST_TERMNO; diff --git a/src/dircolors.hin b/src/dircolors.hin index 5c89447..f557560 100644 --- a/src/dircolors.hin +++ b/src/dircolors.hin @@ -12,16 +12,7 @@ TERM Eterm TERM ansi TERM color-xterm -TERM con132x25 -TERM con132x30 -TERM con132x43 -TERM con132x60 -TERM con80x25 -TERM con80x28 -TERM con80x30 -TERM con80x43 -TERM con80x50 -TERM con80x60 +TERM con[0-9]*x[0-9]* TERM cons25 TERM console TERM cygwin @@ -40,34 +31,14 @@ TERM mach-gnu-color TERM mlterm TERM putty TERM putty-256color -TERM rxvt -TERM rxvt-256color -TERM rxvt-cygwin -TERM rxvt-cygwin-native -TERM rxvt-unicode -TERM rxvt-unicode-256color -TERM rxvt-unicode256 -TERM screen -TERM screen-256color -TERM screen-256color-bce -TERM screen-bce -TERM screen-w -TERM screen.Eterm -TERM screen.rxvt -TERM screen.linux +TERM rxvt* +TERM screen* TERM st TERM st-256color TERM terminator -TERM tmux -TERM tmux-256color +TERM tmux* TERM vt100 -TERM xterm -TERM xterm-16color -TERM xterm-256color -TERM xterm-88color -TERM xterm-color -TERM xterm-debian -TERM xterm-termite +TERM xterm* # Below are the color init strings for the basic file types. A color init # string consists of one or more of the following numeric codes: diff --git a/tests/misc/dircolors.pl b/tests/misc/dircolors.pl index b9f8a1d..2e6f27d 100755 --- a/tests/misc/dircolors.pl +++ b/tests/misc/dircolors.pl @@ -33,6 +33,14 @@ my @Tests = . "export LS_COLORS\n"}], ['other-wr', '-b', {IN => "owt 40;33\n"}, {OUT => "LS_COLORS='tw=40;33:';\nexport LS_COLORS\n"}], + ['term-1', '-b', {IN => "TERM none\nowt 40;33\n"}, + {OUT => "LS_COLORS='tw=40;33:';\nexport LS_COLORS\n"}], + ['term-2', '-b', {IN => "TERM non*\nowt 40;33\n"}, + {OUT => "LS_COLORS='tw=40;33:';\nexport LS_COLORS\n"}], + ['term-3', '-b', {IN => "TERM nomatch\nowt 40;33\n"}, + {OUT => "LS_COLORS='';\nexport LS_COLORS\n"}], + ['term-4', '-b', {IN => "TERM N*match\nowt 40;33\n"}, + {OUT => "LS_COLORS='';\nexport LS_COLORS\n"}], # CAREFUL: always specify the -b option, unless explicitly testing # for csh syntax output. -- 2.5.0