1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-14 07:46:28 +02:00

(check_symlink_color): New variable.

(main): Set it if we need to check for dangling symlinks when
displaying colors.
(gobble_file): Check check_symlink_color instead of print_with_color.
This commit is contained in:
Jim Meyering
1999-12-04 16:55:27 +00:00
parent c4542a7e8c
commit 2be3dc067a

View File

@@ -478,6 +478,11 @@ static struct color_ext_type *color_ext_list = NULL;
/* Buffer for color sequences */
static char *color_buf;
/* Nonzero means to check for orphaned symbolic link, for displaying
colors. */
static int check_symlink_color;
/* Nonzero means mention the inode number of each file. -i */
static int print_inode;
@@ -763,6 +768,11 @@ main (int argc, char **argv)
{
parse_ls_color ();
prep_non_filename_text ();
/* Avoid following symbolic links when possible. */
if (color_indicator[C_ORPHAN].string != NULL
|| (color_indicator[C_MISSING].string != NULL
&& format == long_format))
check_symlink_color = 1;
}
format_needs_stat = sort_type == sort_time || sort_type == sort_size
@@ -1764,7 +1774,7 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
}
if (S_ISLNK (files[files_index].stat.st_mode)
&& (explicit_arg || format == long_format || print_with_color))
&& (explicit_arg || format == long_format || check_symlink_color))
{
char *linkpath;
struct stat linkstats;
@@ -1777,7 +1787,7 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
if (linkpath
&& ((explicit_arg && format != long_format)
|| indicator_style != none
|| print_with_color)
|| check_symlink_color)
&& stat (linkpath, &linkstats) == 0)
{
files[files_index].linkok = 1;