[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
LS_COLORS
From: |
Peter 'Luna' Runestig |
Subject: |
LS_COLORS |
Date: |
Thu, 29 Nov 2001 21:22:01 +0100 |
Hi!
I had a problem with color ls from fileutils-4.1, it tries to use colors on
an unsupported TERM (i.e. an empty or non-existent $LS_COLORS), and that
messes up my homebrewed telnet client. Here is a pacth to fix it, but maybe
it's not how you would solve it (but solved it should be):
diff -ur fileutils-4.1.orig/src/ls.c fileutils-4.1/src/ls.c
--- fileutils-4.1.orig/src/ls.c Sun Apr 29 11:42:47 2001
+++ fileutils-4.1/src/ls.c Wed Nov 28 11:51:40 2001
@@ -327,7 +327,7 @@
static void print_with_commas PARAMS ((void));
static void queue_directory PARAMS ((const char *name, const char
*realname));
static void sort_files PARAMS ((void));
-static void parse_ls_color PARAMS ((void));
+static int parse_ls_color PARAMS ((void));
void usage PARAMS ((int status));
/* The name the program was run with, stripped of any leading path. */
@@ -865,9 +865,8 @@
i = decode_switches (argc, argv);
- if (print_with_color)
+ if (print_with_color && parse_ls_color())
{
- parse_ls_color ();
prep_non_filename_text ();
/* Avoid following symbolic links when possible. */
if (color_indicator[C_ORPHAN].string != NULL
@@ -875,6 +874,8 @@
&& format == long_format))
check_symlink_color = 1;
}
+ else
+ print_with_color = 0;
format_needs_stat = sort_type == sort_time || sort_type == sort_size
|| format == long_format
@@ -1587,7 +1588,7 @@
return state == ST_ERROR ? -1 : count;
}
-static void
+static int
parse_ls_color (void)
{
const char *p; /* Pointer to character being parsed */
@@ -1598,7 +1599,7 @@
struct color_ext_type *ext; /* Extension we are working on */
if ((p = getenv ("LS_COLORS")) == NULL || *p == '\0')
- return;
+ return 0; /* 0 means "don't use colors!" */
ext = NULL;
strcpy (label, "??");
@@ -1712,6 +1713,8 @@
if (color_indicator[C_LINK].len == 6
&& !strncmp (color_indicator[C_LINK].string, "target", 6))
color_symlink_as_referent = 1;
+
+ return 1;
}
/* Request that the directory named `name' have its contents listed later.
Cheers,
- Peter
----------------------------------------------------------------
Peter 'Luna' Runestig (fd. Altberg), Sweden <address@hidden>
PGP Key ID: 0xD07BBE13
Fingerprint: 7B5C 1F48 2997 C061 DE4B 42EA CB99 A35C D07B BE13
AOL Instant Messenger Screenname: PRunestig
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- LS_COLORS,
Peter 'Luna' Runestig <=