bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coreutils regression in ls: link color "target"


From: Jim Meyering
Subject: Re: coreutils regression in ls: link color "target"
Date: Sat, 07 Apr 2007 20:54:41 +0200

Eric Blake <address@hidden> wrote:
> Since I don't have access to a machine with d_type right now, I wonder if this
> is the right fix:
>
> diff --git a/src/ls.c b/src/ls.c
> index abb0a26..c85b333 100644

Thanks for the patch.
That looks right to me, too, so I've made the following changes:
(not yet pushed)

diff --git a/ChangeLog b/ChangeLog
index 46b7b02..f95dcfd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-04-07  Eric Blake  <address@hidden>
+
+       Fix a bug in how the LS_COLORS ln=target attribute is handled.
+       * src/ls.c (gobble_file): Use "stat" (not lstat) also when the
+       ln=target attribute applies.  Reported by Kirk Kelsey.
+
 2007-04-02  Jim Meyering  <address@hidden>

        * src/copy.c (copy_reg): Initialize local "con", before calling
diff --git a/src/ls.c b/src/ls.c
index abb0a26..6ee6775 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2577,7 +2577,8 @@ gobble_file (char const *name, enum filetype type, ino_t 
inode,
       || ((print_inode || format_needs_type)
          && (type == symbolic_link || type == unknown)
          && (dereference == DEREF_ALWAYS
-             || (command_line_arg && dereference != DEREF_NEVER)))
+             || (command_line_arg && dereference != DEREF_NEVER)
+             || color_symlink_as_referent))
       /* Command line dereferences are already taken care of by the above
         assertion that the inode number is not yet known.  */
       || (print_inode && inode == NOT_AN_INODE_NUMBER)


diff --git a/ChangeLog b/ChangeLog
index f95dcfd..a40c398 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-04-07  Jim Meyering  <address@hidden>
+
+       Add a test for, and document, today's fix.
+       * NEWS: Mention today's ls --color fix.
+       * tests/ls-2/tests (sl-target): Add a test for today's fix.
+       * THANKS: Add Kirk Kelsey.
+
 2007-04-07  Eric Blake  <address@hidden>

        Fix a bug in how the LS_COLORS ln=target attribute is handled.
diff --git a/NEWS b/NEWS
index 6dee2cb..c1e4bf9 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,10 @@ GNU coreutils NEWS                                    -*- 
outline -*-
   ls -x DIR would sometimes output the wrong string in place of the
   first entry.  [introduced in coreutils-6.8]

+  ls --color, (with a custom LS_COLORS envvar value including the
+  ln=target attribute) would mistakenly output the string "target"
+  before the name of each symlink.  [introduced in coreutils-6.0]
+

 * Noteworthy changes in release 6.9 (2007-03-22) [stable]

diff --git a/THANKS b/THANKS
index ad05b13..b353b8f 100644
--- a/THANKS
+++ b/THANKS
@@ -274,6 +274,7 @@ Keith Owens                         address@hidden
 Keith Thompson                      address@hidden
 Ken Pizzini                         address@hidden
 Kevin Mudrick                       address@hidden
+Kirk Kelsey                         address@hidden
 Kristin E Thomas                    address@hidden
 Kjetil Torgrim Homme                address@hidden
 Kristoffer Rose                     address@hidden
diff --git a/tests/ls-2/tests b/tests/ls-2/tests
index d0257a6..3f2fc1d 100755
--- a/tests/ls-2/tests
+++ b/tests/ls-2/tests
@@ -1,8 +1,7 @@
 #!/bin/sh
 # -*- perl -*-

-# Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free
-# Software Foundation, Inc.
+# Copyright (C) 1998, 2000-2007 Free Software Foundation, Inc.

 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -58,6 +57,13 @@ my $mkdir2 = {PRE => sub {mkdir 'd',0755 or die "d: $!\n";
 my $rmdir2 = {POST => sub {rmdir 'd/e' or die "d/e: $!\n";
                           rmdir 'd' or die "d: $!\n" }};

+my $target = {PRE => sub {
+               mkdir 'd',0755 or die "d: $!\n";
+               symlink '.', 'd/X' or die "d/X: $!\n";
+               $ENV{LS_COLORS}='ln=target'
+             }};
+my $target2 = {POST => sub {unlink 'd/X' or die "d/X: $!\n";
+                           rmdir 'd' or die "d: $!\n" }};
 my $slink_d = {PRE => sub {symlink '/', 'd' or die "d: $!\n";
                            $ENV{LS_COLORS}='ln=01;36:di=01;34:or=40;31;01'
                            }};
@@ -120,6 +126,10 @@ my @Tests =
                                 {OUT => "\e[0m\e[01;address@hidden"},
                                  $slink_d, $unlink_d],

+     # Test for a bug fixed in coreutils-6.10.
+     ['sl-target', '--color=always d',
+      {OUT => "\e[0m\e[01;34mX\e[0m\n\e[m"}, $target, $target2],
+
      # 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]