From b7f2b51c42edabd516c5ecc748a654da736c912c Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 1 Jan 2010 07:39:29 -0700 Subject: ls: fix color of broken symlinks colored as target * src/ls.c (print_color_indicator): When using 'LINK target' in dircolors, treat broken symlink as C_ORPHAN. * tests/misc/ls-misc (sl-dangle2, sl-dangle3, sl-dangle4) (sl-dangle5): Test for it, and add more coverage. * NEWS: Document it. * THANKS: Update. Reported by Chris Jones. --- tests/misc/ls-misc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests/misc') diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc index a0774829a..27de57c79 100755 --- a/tests/misc/ls-misc +++ b/tests/misc/ls-misc @@ -185,6 +185,44 @@ my @Tests = restore_ls_colors; }}, ], + # Test for a bug fixed after coreutils-8.2. + ['sl-dangle2', '-o --color=always l', + {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'}, + {OUT => "l -> nowhere\n"}, + {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; + push_ls_colors('ln=target') + }}, + {POST => sub {unlink 'l' or die "l: $!\n"; + restore_ls_colors; }}, + ], + ['sl-dangle3', '-o --color=always l', + {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'}, + {OUT => "$e\e[40ml$e -> \e[34mnowhere$e\n\e[m"}, + {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; + push_ls_colors('ln=target:or=40:mi=34:') + }}, + {POST => sub {unlink 'l' or die "l: $!\n"; + restore_ls_colors; }}, + ], + ['sl-dangle4', '-o --color=always l', + {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'}, + {OUT => "$e\e[36ml$e -> \e[35mnowhere$e\n\e[m"}, + {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; + push_ls_colors('ln=34:mi=35:or=36:') + }}, + {POST => sub {unlink 'l' or die "l: $!\n"; + restore_ls_colors; }}, + ], + ['sl-dangle5', '-o --color=always l', + {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'}, + {OUT => "$e\e[34ml$e -> \e[35mnowhere$e\n\e[m"}, + {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; + push_ls_colors('ln=34:mi=35:') + }}, + {POST => sub {unlink 'l' or die "l: $!\n"; + restore_ls_colors; }}, + ], + # Test for a bug that was introduced in coreutils-4.5.4; fixed in 4.5.5. # To demonstrate it, the file in question (with executable bit set) # must not be a command line argument. -- cgit v1.2.3-70-g09d2