mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
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.
This commit is contained in:
1 parent
84db964925
commit
b7f2b51c42
4 files changed
+46
-1
No files matched your search
@@ -4,6 +4,10 @@ GNU coreutils NEWS -*- outline -*-
|
|||||||
|
|
||||||
** Bug fixes
|
** Bug fixes
|
||||||
|
|
||||||
|
ls -l --color no longer prints "argetm" in front of dangling
|
||||||
|
symlinks when the 'LINK target' directive was given to dircolors.
|
||||||
|
[bug introduced in fileutils-4.0]
|
||||||
|
|
||||||
rm -r --one-file-system works once again.
|
rm -r --one-file-system works once again.
|
||||||
The rewrite to make rm use fts introduced a regression whereby
|
The rewrite to make rm use fts introduced a regression whereby
|
||||||
a commmand of the above form would fail for all subdirectories.
|
a commmand of the above form would fail for all subdirectories.
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ Chip Salzenberg chip@valinux.com
|
|||||||
Chris Clayton chris2553@googlemail.com
|
Chris Clayton chris2553@googlemail.com
|
||||||
Chris Faylor cgf@cygnus.com
|
Chris Faylor cgf@cygnus.com
|
||||||
Chris J. Bednar cjb@AdvancedDataSolutions.com
|
Chris J. Bednar cjb@AdvancedDataSolutions.com
|
||||||
|
Chris Jones cjns1989@gmail.com
|
||||||
Chris Lesniewski ctl@mit.edu
|
Chris Lesniewski ctl@mit.edu
|
||||||
Chris Sylvain csylvain@umm.edu
|
Chris Sylvain csylvain@umm.edu
|
||||||
Chris Yeo cyeo@biking.org
|
Chris Yeo cyeo@biking.org
|
||||||
|
|||||||
@@ -4164,7 +4164,9 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target)
|
|||||||
type = C_STICKY;
|
type = C_STICKY;
|
||||||
}
|
}
|
||||||
else if (S_ISLNK (mode))
|
else if (S_ISLNK (mode))
|
||||||
type = ((!linkok && color_indicator[C_ORPHAN].string)
|
type = ((!linkok
|
||||||
|
&& (!strncmp (color_indicator[C_LINK].string, "target", 6)
|
||||||
|
|| color_indicator[C_ORPHAN].string))
|
||||||
? C_ORPHAN : C_LINK);
|
? C_ORPHAN : C_LINK);
|
||||||
else if (S_ISFIFO (mode))
|
else if (S_ISFIFO (mode))
|
||||||
type = C_FIFO;
|
type = C_FIFO;
|
||||||
|
|||||||
@@ -185,6 +185,44 @@ my @Tests =
|
|||||||
restore_ls_colors; }},
|
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.
|
# 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)
|
# To demonstrate it, the file in question (with executable bit set)
|
||||||
# must not be a command line argument.
|
# must not be a command line argument.
|
||||||
|
|||||||
Reference in new issue
Block a user