bugGNU Core Utilities - Bugs: bug #15043, ls assigns colors inconsistently

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #15043: ls assigns colors inconsistently

Submitter:  None
Submitted:  Thu 24 Nov 2005 03:14:56 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Sat 26 Aug 2006 10:42:21 AM UTC, comment #4: 

Thanks again.
I've just checked in a fix for coreutils-6.2: http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/7917

Jim Meyering <meyering>
Group administrator
Tue 25 Jul 2006 12:35:36 AM UTC, comment #3: 

Ok, I have tested a patch. In gobble_file, in the conditional starting 'if (command_line_arg' (the second 'if'), adding the condition '|| (type == directory && print_with_color)' fixes the problem, at least with the build I just did. Because this is only a problem on Linux, I think I would wrap it in a 'Linux-only' preprocessor directive (I'm not sure what to use, which is the only reason why I did not make an actual .patch).

...And I see I missed the OP's "Diagnosis" and "Possible solutions" the first time I read this; sorry about that.

Matthew Woehlke <woehlkmp>
Fri 21 Jul 2006 01:03:33 AM UTC, comment #2: 

FWIW, I have now tested on HP-UX (both 9000/800 and Itanium), Solaris (SPARC and x86), Tru64, AIX, and of course Linux (x86). Of the above, it is ONLY broken on Linux.

Matthew Woehlke <woehlkmp>
Thu 06 Jul 2006 10:40:33 PM UTC, comment #1: 

I can reproduce this with 5.97 on x86 Linux, but it works on x86 Solaris. Nothing in the source code seems to indicate why this would be broken; any guesses?

Matthew Woehlke <woehlkmp>
Thu 24 Nov 2005 03:14:56 AM UTC, original submission:  

Package:
    GNU core utilities

Version:
    5.93

Utility:
    ls

Bug summary:
    ls assigns colors inconsistently.

Bug reproduction:
    unset $LS_COLORS
    mkdir -m 1777 tmp
    ls --color -l
    ls --color

Expected output:
    tmp is colored black on green for both invocations of ls.

Actual output:
    tmp is colored black on green on the first invocation of ls but
    bright blue on the second invocation of ls.

Relevant package file:
    coreutils-5.93/src/ls.c

Diagnosis:
    With -l, gobble_file() does stat() tmp, f->stat.st_mode encodes
    file type, UID/GID/sticky and permissions, and
    print_color_indicator() assigns type = C_STICKY_OTHER_WRITABLE
    (black on green by default) based on all three st_mode bitfields.
    Without -l, gobble_file() doesn't stat() tmp,
    f->stat.st_mode = DTTOIF (type) encodes file type, and
    print_color_indicator() assigns type = C_DIR (bright blue by
    default) based only on one st_mode bitfield.

Possible solutions:
    * In print_color_indicator(), eliminate UID/GID/sticky and
      permissions coloring for directories
    * In gobble_file(), stat() if print_with_color
    * In gobble_file(), stat() if (type == directory && print_with_color)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 3 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-08-26 meyering Open/ClosedOpen Closed
2006-08-26 meyering StatusNone Fixed
2006-07-21 woehlkmp Carbon-Copy- Added woehlkmp

Back to the top

Powered by Savane 3.13-d3ae.
Corresponding source code