GNU bug report logs - #12445
ls --color does not color symlinks when not resolving them

Previous Next

Package: coreutils;

Reported by: Matei David <matei <at> cs.toronto.edu>

Date: Fri, 14 Sep 2012 17:06:01 UTC

Severity: normal

Tags: fixed, notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #15 received at 12445 <at> debbugs.gnu.org (full text, mbox):

From: Matei David <matei <at> cs.toronto.edu>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 12445 <at> debbugs.gnu.org
Subject: Re: bug#12445: ls --color does not color symlinks when not
	resolving them
Date: Fri, 14 Sep 2012 22:28:06 -0400
On Sat, 15 Sep 2012 00:55:12 +0100
Pádraig Brady <P <at> draigBrady.com> wrote:

> tag 12445 + notabug
> close 12445
> stop
> 
> On 09/14/2012 05:54 PM, Matei David wrote:
> > When the ORPHAN property is disabled in dircolors, ls --color does not
> > stat() symlinks. However, in this case symlinks are not colored using the
> > LINK property.
> >
> > How to reproduce:
> > $ eval $(dircolors -p | sed 's/^ORPHAN.*/ORPHAN 00/' | dircolors -)
> > $ mkdir /tmp/xxx
> > $ ln -s /tmp/nowhere /tmp/xxx/yyy
> > $ ls --color /tmp/xxx
> >
> > Expected output:
> > yyy, colored cyan (default for LINK)
> >
> > Actual output:
> > yyy, not colored
> >
> > Fix attached. Basically, in gobble_file(), assume a symlink is ok if stat()
> > is not run on it.
> 
> It seems this was fixed over 5 years ago in version 6.9
> http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commit;h=0a744370
> Are you using an older version than that?
> 
> I'm marking as done for now.
> 
> thanks,
> Pádraig.

I'm using coreutils 8.19. There are 2 lines which ever modify f->linkok (both
set it to true): 2700 and 2720. Both are inside the if block starting at
line 2560. By design, the if block is _not_ executed under the conditions I laid
out above in order to avoid both fstat() and stat() calls on the symlink (which
is ok!) However, the coloring is missing. Did you try my code?

The bug you mention was about avoiding the stat() call, i.e. following the
link. There is also this one, related:
http://git.savannah.gnu.org/cgit/coreutils.git/commit/src/ls.c?id=a085b6fc6c8fa03dac20f01f2f2b64b50b8bdf66

The behaviour I observe is: no fstat(), no stat(), (great so far...) but no
color either- that's the bug.




This bug report was last modified 6 years and 224 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.