bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Add a configuration file for dircolors' default colors [patch]


From: Anthony DeRobertis
Subject: Add a configuration file for dircolors' default colors [patch]
Date: Sun, 13 Nov 2005 13:33:17 -0500
User-agent: Mutt/1.5.9i

[ Plase cc me on replies; I'm not subscribed. I've attempted to set
  mail-followup-to, but no guarantees I got it right. ]

"dircolors" uses a compiled-in set of default colors. This makes it hard
for the sysadmin to change the defaults. Here is a patch which makes it
look in /etc/dircolors.conf for the defaults, and fall back to the
compiled-in ones if that file is not present.

diff -Nru3 ./coreutils-5.2.1/src/dircolors.c 
../build-tree.new/coreutils-5.2.1/src/dircolors.c
--- ./coreutils-5.2.1/src/dircolors.c   2004-01-21 17:27:02.000000000 -0500
+++ ../build-tree.new/coreutils-5.2.1/src/dircolors.c   2005-11-13 
12:04:16.000000000 -0500
@@ -375,7 +375,7 @@
 }
 
 static int
-dc_parse_file (const char *filename)
+dc_parse_file (const char *filename, int ignore_open_fail)
 {
   FILE *fp;
   int err;
@@ -394,6 +394,10 @@
       fp = fopen (filename, "r");
       if (fp == NULL)
        {
+         if (ignore_open_fail)
+           {
+             return -1;
+           }
          error (0, errno, "%s", quote (filename));
          return 1;
        }
@@ -500,9 +504,13 @@
 
       obstack_init (&lsc_obstack);
       if (argc == 0)
-       err = dc_parse_stream (NULL, NULL);
+       {
+         err = dc_parse_file("/etc/dircolors.conf", 1);
+         if (-1 == err)
+           err = dc_parse_stream (NULL, NULL);
+       }
       else
-       err = dc_parse_file (argv[0]);
+       err = dc_parse_file (argv[0], 0);
 
       if (!err)
        {
@@ -533,3 +541,5 @@
 
   exit (err == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+
+/* vim: set ts=8 sw=2: */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]