Hi, Here is a patch for fileutils-4.0 to add support for colorization of read-only files in the output of "ls". I find it usefull to have different colors for read-write and read-only files. For instance, when you are using a version control system, you can easily identify the files that are checked out for editing. As long as you don't specify a color for read-only files with the "ro" code, the behavior should be the same as before. -- Dick Streefland //// TASKING Software BV [EMAIL PROTECTED] (@ @) http://www.tasking.com --------------------------------oOO--(_)--OOo--------------------------- --- fileutils-4.0/src/dircolors.c.ro Sat Sep 19 19:09:23 1998 +++ fileutils-4.0/src/dircolors.c Tue Feb 22 14:02:10 2000 @@ -68,13 +68,13 @@ "NORMAL", "NORM", "FILE", "DIR", "LNK", "LINK", "SYMLINK", "ORPHAN", "MISSING", "FIFO", "PIPE", "SOCK", "BLK", "BLOCK", "CHR", "CHAR", "EXEC", "LEFT", "LEFTCODE", "RIGHT", "RIGHTCODE", "END", - "ENDCODE", NULL + "ENDCODE", "READONLY", NULL }; static const char *const ls_codes[] = { "no", "no", "fi", "di", "ln", "ln", "ln", "or", "mi", "pi", "pi", - "so", "bd", "bd", "cd", "cd", "ex", "lc", "lc", "rc", "rc", "ec", "ec" + "so", "bd", "bd", "cd", "cd", "ex", "lc", "lc", "rc", "rc", "ec", "ec", "ro" }; static struct option const long_options[] = --- fileutils-4.0/src/dircolors.hin.ro Mon Jun 23 13:42:03 1997 +++ fileutils-4.0/src/dircolors.hin Tue Feb 22 14:18:10 2000 @@ -30,6 +30,7 @@ # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white NORMAL 00 # global default, although everything should be something. FILE 00 # normal file +READONLY 00 # read-only file DIR 01;34 # directory LINK 01;36 # symbolic link FIFO 40;33 # pipe --- fileutils-4.0/src/ls.c.ro Tue Feb 22 13:49:25 2000 +++ fileutils-4.0/src/ls.c Tue Feb 22 14:17:21 2000 @@ -367,13 +367,13 @@ enum indicator_no { - C_LEFT, C_RIGHT, C_END, C_NORM, C_FILE, C_DIR, C_LINK, C_FIFO, C_SOCK, + C_LEFT, C_RIGHT, C_END, C_NORM, C_RO, C_FILE, C_DIR, C_LINK, C_FIFO, C_SOCK, C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC }; static const char *const indicator_name[]= { - "lc", "rc", "ec", "no", "fi", "di", "ln", "pi", "so", + "lc", "rc", "ec", "no", "ro", "fi", "di", "ln", "pi", "so", "bd", "cd", "mi", "or", "ex", NULL }; @@ -390,6 +390,7 @@ { LEN_STR_PAIR ("m") }, /* rc: Right of color sequence */ { 0, NULL }, /* ec: End color (replaces lc+no+rc) */ { LEN_STR_PAIR ("0") }, /* no: Normal */ + { LEN_STR_PAIR ("0") }, /* ro: Read only */ { LEN_STR_PAIR ("0") }, /* fi: File: default */ { LEN_STR_PAIR ("01;34") }, /* di: Directory: bright blue */ { LEN_STR_PAIR ("01;36") }, /* ln: Symlink: bright cyan */ @@ -2509,12 +2510,17 @@ type = C_CHR; #endif - if (type == C_FILE && (mode & S_IXUGO) != 0) - type = C_EXEC; + if (type == C_FILE) + { + if ((mode & S_IXUGO) != 0) + type = C_EXEC; + else if ((mode & (S_IWUSR|S_IWGRP|S_IWOTH)) == 0) + type = C_RO; + } - /* Check the file's suffix only if still classified as C_FILE. */ + /* Check the file's suffix only if still classified as C_FILE or C_RO. */ ext = NULL; - if (type == C_FILE) + if (type == C_FILE || type == C_RO) { /* Test if NAME has a recognized suffix. */
