bug-coreutils
[Top][All Lists]
Advanced

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

[PATCH] ls: support disabling colors on all subtypes


From: Pádraig Brady
Subject: [PATCH] ls: support disabling colors on all subtypes
Date: Mon, 14 Sep 2009 16:13:24 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

I was trying to disable the green colors today in my ls listing
and noticed that if you do that the directories are shown
without color rather than falling back to the standard color
for directories (blue).

The attached patch fixes that up.

cheers,
Pádraig.
>From 26a6061d88728d1c2895c3148b061fa4f066d87b Mon Sep 17 00:00:00 2001
From: =?utf-8?q?P=C3=A1draig=20Brady?= <address@hidden>
Date: Mon, 14 Sep 2009 13:37:37 +0100
Subject: [PATCH] ls: support disabling colors on all subtypes

* src/ls.c (print_color_indicator): Use consistent syntax for
all file and directory subtypes, and fall back to the color
of the base type if there is no enabled color for the subtype.
This allows turning off specific colors for o+w dirs for example.
---
 src/ls.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/ls.c b/src/ls.c
index b62ea12..efdc0b4 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -4102,7 +4102,7 @@ print_color_indicator (const char *name, mode_t mode, int 
linkok,
                        bool stat_ok, enum filetype filetype,
                        nlink_t nlink)
 {
-  int type;
+  enum indicator_no type;
   struct color_ext_type *ext;  /* Color extension */
   size_t len;                  /* Length of name */
 
@@ -4120,27 +4120,29 @@ print_color_indicator (const char *name, mode_t mode, 
int linkok,
       if (S_ISREG (mode))
         {
           type = C_FILE;
-          if ((mode & S_ISUID) != 0)
+
+          if ((mode & S_ISUID) != 0 && is_colored (C_SETUID))
             type = C_SETUID;
-          else if ((mode & S_ISGID) != 0)
+          else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))
             type = C_SETGID;
-          else if (is_colored (C_CAP) && has_capability (name))
+          else if (has_capability (name) && is_colored (C_CAP))
             type = C_CAP;
-          else if ((mode & S_IXUGO) != 0)
+          else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
             type = C_EXEC;
-          else if (is_colored (C_MULTIHARDLINK) && (1 < nlink))
+          else if ((1 < nlink) && is_colored (C_MULTIHARDLINK))
             type = C_MULTIHARDLINK;
         }
       else if (S_ISDIR (mode))
         {
-          if ((mode & S_ISVTX) && (mode & S_IWOTH))
+          type = C_DIR;
+
+          if ((mode & S_ISVTX) && (mode & S_IWOTH)
+              && is_colored (C_STICKY_OTHER_WRITABLE))
             type = C_STICKY_OTHER_WRITABLE;
-          else if ((mode & S_IWOTH) != 0)
+          else if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE))
             type = C_OTHER_WRITABLE;
-          else if ((mode & S_ISVTX) != 0)
+          else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY))
             type = C_STICKY;
-          else
-            type = C_DIR;
         }
       else if (S_ISLNK (mode))
         type = ((!linkok && color_indicator[C_ORPHAN].string)
-- 
1.6.2.5


reply via email to

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