ls --color=auto will try to colorize when LS_COLORS is null. LS_COLORS
is set null for example by the dircolors program when there is a
terminal (like dumb) that is not known to be able to color.
Below is a patch that works, although I'm don't think it is the *best*
patch.
The idea in the patch below is that if parse_ls_color finds the null
string it sets the variable to colorize (print_with_color) off.
My taste would be to change parse_ls_color into a function which
returns false if parsing fails or the LS_COLORS environment variable
is the null string.
So instead of:
if (print_with_color)
in the fileutils 4.0 code, we might have
if (print_with_color && prep_non_filename_text())
I've checked the fileutils 4.0x pachage on alpha.gnu.org and the
situation is the same there.
*** ls-orig.c Sat Sep 19 13:09:23 1998
--- ls.c Sun Aug 6 15:13:47 2000
***************
*** 709,715 ****
if (print_with_color)
{
parse_ls_color ();
! prep_non_filename_text ();
}
format_needs_stat = sort_type == sort_time || sort_type == sort_size
--- 709,715 ----
if (print_with_color)
{
parse_ls_color ();
! if (print_with_color) prep_non_filename_text ();
}
format_needs_stat = sort_type == sort_time || sort_type == sort_size
***************
*** 1413,1421 ****
struct col_ext_type *ext; /* Extension we are working on */
struct col_ext_type *ext2; /* Extra pointer */
! if ((p = getenv ("LS_COLORS")) == NULL || *p == '\0')
return;
ext = NULL;
strcpy (label, "??");
--- 1413,1426 ----
struct col_ext_type *ext; /* Extension we are working on */
struct col_ext_type *ext2; /* Extra pointer */
! if ((p = getenv ("LS_COLORS")) == NULL)
return;
+ if (*p == '\0') {
+ print_with_color = 0;
+ return;
+ }
+
ext = NULL;
strcpy (label, "??");