[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: coreutils regression in ls: link color "target"
From: |
Eric Blake |
Subject: |
Re: coreutils regression in ls: link color "target" |
Date: |
Thu, 5 Apr 2007 18:07:32 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Kirk Kelsey <kirk.kelsey <at> 0x4b.net> writes:
>
> On Apr 4, 2007, at 10:44 PM, Eric Blake wrote:
> >
> > What do the following show?
> >
> > echo $LS_COLORS
> > ls -C --color=always ~/ | od -tx1z
> >
> here are the results (with the newer, "incorrect" output before the
> older expected output of ls)
>
> kelsey <at> a21 $ echo $LS_COLORS
> no=00:fi=00:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:ln=target:or=01;37
...
> kelsey <at> a21 $ /tmp/coreutils-6.9/src/ls -C --color=always ~/ | od -tx1z
...
> 0000220 55 4e 57 41 4e 54 45 44 1b 5b 30 30 6d 20 20 1b >UNWANTED.
> [00m .<
> 0000240 5b 74 61 72 67 65 74 6d 63 6f 6d 70 69 6c 65 72 >
> [targetmcompiler<
Indeed. In your case, ls is outputting a literal "target" instead of using the
formatting characters of the dereferenced file type. This is indeed a
regression. I assume you were on Linux, where dirent.d_type is valid, since I
couldn't reproduce this on cygwin where d_type is missing?
This is the simpler testcase I was using:
$ mkdir ls
$ cd ls
$ touch foo
$ ln -s foo bar
$ LS_COLORS='ln=target:fi=01;35:' ~/coreutils/src/ls --color -F | od -tx1z
0000000 1b 5b 30 6d 1b 5b 30 31 3b 33 35 6d 62 61 72 1b >.[0m.[01;35mbar.<
0000020 5b 30 6d 40 0a 1b 5b 30 31 3b 33 35 6d 66 6f 6f >address@hidden;35mfoo<
0000040 1b 5b 30 6d 0a 1b 5b 6d >.[0m..[m<
0000050
$ # Note that both files printed with magenta
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
--- a/src/ls.c
+++ b/src/ls.c
@@ -2577,7 +2577,8 @@ gobble_file (char const *name, enum filetype type, ino_t i
node,
|| ((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)
--
Eric Blake