summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-12-04 16:55:27 +0000
committerJim Meyering <jim@meyering.net>1999-12-04 16:55:27 +0000
commit2be3dc067ac98bbf165f8d0dbd7c799128cb9d0b (patch)
tree457b86c34698b5a838f750b9b4cef1eefcc191c9 /src
parentc4542a7e8c8a283e6e8e5582e8f14269f9a05632 (diff)
downloadcoreutils-2be3dc067ac98bbf165f8d0dbd7c799128cb9d0b.tar.xz
(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.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ls.c b/src/ls.c
index af7e5d710..c38d93a50 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -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;