Subject: bug#15992: 'ls' ignores term capabilities when generating color.

From: Guilherme de Almeida Suckevicz <[email-masked]>
Date: Wed, 16 Apr 2014 10:51:00 -0300

Hi Pádraig,

I made a patch for this issue according to the tips above.
I hope that is ok!

[guilherme@almeida build]$ diff ../src/ls.c ../src/ls-orig.c
111d110
< #include "dircolors.h"
2330,2360d2328
<
< /* GCC warning about pure attribute. */
< bool check_term_type (const char *) __attribute__ ((pure));
<
< /* Check if the content of TERM is a valid name in dirname.h . */
< bool
< know_term_type (void)
< {
<   char const *line;
<   const char *term;
<
<   term = getenv ("TERM");
<   if (! term || ! *term)
<     return false;
<
<   line = G_line;
<   while (line - G_line < sizeof (G_line))
<     {
<       /* Get just lines begining with 'TERM '. */
<       if (STRNCMP_LIT (line, "TERM ") == 0)
<     {
<       if (STREQ (term, line + 5))
<         return true;
<     }
<
<       line += strlen (line) + 1;
<     }
<
<   return false;
< }
<
2370d2337
<
2372,2382c2339
<     {
<       /* If COLORTERM is not set, check if the term type is know. */
<       if (getenv ("COLORTERM") == NULL)
<     {
<       if (! know_term_type ())
<         {
<           print_with_color = false;
<           return;
<         }
<     }
<     }
---
>     return;

Thank you very much for help me! :D
Guilherme Almeida.