From a04ddb8dd3fffd3457f927a36f6840fc1465aba2 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Sun, 16 Sep 2012 04:10:50 +0100 Subject: ls: fix coloring of dangling symlinks in default listing mode When listing a directory containing dangling symlinks, and not outputting a long format listing, and orphaned links are set to no coloring in LS_COLORS, then the symlinks would get no color rather than reverting to the standard symlink color. The issue was introduced in v8.13-19-g84457c4 * src/ls.c (print_color_indicator): Use the standard method to check if coloring is specified for orphaned symlinks. The existing method would consider 'or=00' or 'or=0' as significant in LS_COLORS. Even 'or=' was significant as in that case the string='or=' and the length=0. Also apply the same change for missing symlinks for consistency. (gobble_file): Remove the simulation of linkok, which is only tested in print_color_indicator() which now handles this directly by keying on the LS_COLORS values correctly. * tests/misc/ls-misc.pl: Add a test case. * THANKS: Add the reporter. * NEWS: Mention the fix. Reported-by: David Matei --- src/ls.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ls.c b/src/ls.c index 9494ae919..106d234f2 100644 --- a/src/ls.c +++ b/src/ls.c @@ -3064,12 +3064,6 @@ gobble_file (char const *name, enum filetype type, ino_t inode, free (linkname); } - /* When not distinguishing types of symlinks, pretend we know that - it is stat'able, so that it will be colored as a regular symlink, - and not as an orphan. */ - if (S_ISLNK (f->stat.st_mode) && !check_symlink_color) - f->linkok = true; - if (S_ISLNK (f->stat.st_mode)) f->filetype = symbolic_link; else if (S_ISDIR (f->stat.st_mode)) @@ -4293,7 +4287,7 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target) /* Is this a nonexistent file? If so, linkok == -1. */ - if (linkok == -1 && color_indicator[C_MISSING].string != NULL) + if (linkok == -1 && is_colored (C_MISSING)) type = C_MISSING; else if (!f->stat_ok) { @@ -4368,8 +4362,7 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target) /* Adjust the color for orphaned symlinks. */ if (type == C_LINK && !linkok) { - if (color_symlink_as_referent - || color_indicator[C_ORPHAN].string) + if (color_symlink_as_referent || is_colored (C_ORPHAN)) type = C_ORPHAN; } -- cgit v1.2.3-54-g00ecf