diff options
author | Pádraig Brady <P@draigBrady.com> | 2011-10-01 01:47:53 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2011-10-01 02:15:12 +0100 |
commit | 84457c491e775f664a1c33274cd2c5acadb5be73 (patch) | |
tree | 983d17c1a92e99ee1c686e28c468217501f6c5b7 /src/ls.c | |
parent | 4f38e9f24971762540da9d5457dfa9e5e03d53ee (diff) | |
download | coreutils-84457c491e775f664a1c33274cd2c5acadb5be73.tar.xz |
ls: fix output of dangling symlinks colored as target
This is related to commit b7f2b51c, 2010-01-01,
"ls: fix color of broken symlinks colored as target"
which didn't handle the --dereference case.
The simplest way to reproduce the resultant
erroneous "argetm" is as follows:
$ ln -s /no-such dangle
$ env LS_COLORS=ln=target ls --dereference --color
ls: cannot access dangle: No such file or directory
argetmdangle
This is also an issue with the `tree` utility,
reported here: http://bugs.debian.org/586765
* src/ls.c (print_color_indicator): Move the handling
of 'ln=target' in $LS_COLORS (color_symlink_as_referent == true)
to a higher scope, to handle all cases where type == C_LINK.
* tests/misc/ls-misc: Add a test case for the specific issue,
and 2 further test cases to verify other code paths in this area.
Reported by Jason Glassey.
Diffstat (limited to 'src/ls.c')
-rw-r--r-- | src/ls.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -4203,10 +4203,7 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target) type = C_STICKY; } else if (S_ISLNK (mode)) - type = ((!linkok - && (color_symlink_as_referent - || color_indicator[C_ORPHAN].string)) - ? C_ORPHAN : C_LINK); + type = C_LINK; else if (S_ISFIFO (mode)) type = C_FIFO; else if (S_ISSOCK (mode)) @@ -4241,6 +4238,14 @@ 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) + type = C_ORPHAN; + } + { const struct bin_str *const s = ext ? &(ext->seq) : &color_indicator[type]; |