When using "ln=target" in LS_COLORS and having "colored-stats on", I get "targetm" in front of every symlink when using tab-completion, as well as indenting problems. The implementation in lib/readline/colors.c just doesn't work.
I appended a small patch that shows the relevant parts and works well for me. Thanks for bash! Andreas (I am not a subscriber of the list, so please CC me in reply)
--- ./lib/readline/colors.c.orig 2015-03-20 21:29:42.531215281 +0100 +++ ./lib/readline/colors.c 2015-03-20 21:38:11.119857048 +0100 @@ -109,6 +109,7 @@ const char* name; char *filename; struct stat astat; + struct stat lnkstat; mode_t mode; int linkok; @@ -132,6 +133,17 @@ #endif if( stat_ok == 0 ) { mode = astat.st_mode; +#if defined (HAVE_LSTAT) + if (S_ISLNK(mode)) { + if (stat(name, &lnkstat) == -1) { + linkok = 0; + } else { + linkok = 1; + if (strncmp (_rl_color_indicator[C_LINK].string, "target", 6) == 0) + mode = lnkstat.st_mode; + } + } else +#endif linkok = 1; //f->linkok; } else @@ -141,6 +153,8 @@ if (linkok == -1 && _rl_color_indicator[C_MISSING].string != NULL) colored_filetype = C_MISSING; + else if (linkok == 0 && S_ISLNK(mode) && _rl_color_indicator[C_ORPHAN].string != NULL) + colored_filetype = C_ORPHAN; else if(stat_ok != 0) { static enum indicator_no filetype_indicator[] = FILETYPE_INDICATORS; @@ -181,10 +195,7 @@ #endif } else if (S_ISLNK (mode)) - colored_filetype = ((linkok == 0 - && (!strncmp (_rl_color_indicator[C_LINK].string, "target", 6) - || _rl_color_indicator[C_ORPHAN].string)) - ? C_ORPHAN : C_LINK); + colored_filetype = C_LINK; else if (S_ISFIFO (mode)) colored_filetype = C_FIFO; else if (S_ISSOCK (mode))
pgp6v1ntqIjFW.pgp
Description: PGP signature