[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to make the colors different for a symbol link pointing to a fil
From: |
Eric Blake |
Subject: |
Re: How to make the colors different for a symbol link pointing to a file and symbol link pointing to a dir? |
Date: |
Fri, 01 Jan 2010 10:31:35 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 |
According to Jim Meyering on 1/1/2010 8:12 AM:
> Thanks for writing that.
> I'll bet it's right, but I haven't looked carefully yet.
>
>> I still need to figure out how to enhance the testsuite to catch this.
>> Any hints on the best approach to take?
>
> You might want to add one to tests/misc/ls-misc.
Here's what I came up with. OK to squash this with the previous, and push
the fix? Prior to the fix in ls.c, sl-dangle2 fails; sl-dangle3 and
sl-dangle4 just add more coverage to ensure no regressions (it took me a
while to figure out the difference between ORPHAN and MISSING in the
dircolors input file - the coreutils.texi could really use some details
there. ORPHAN is used for dangling symlinks in short listings, and for
the symlink on the left side of the -> in long listings; MISSING is used
for the target of dangling symlinks on the right side of -> in long
listings. If omitted, MISSING defaults to ORPHAN).
Here is the failure, pre-patch:
*** 1,2 ****
! ESC[0mESC[targetmlESC[0m -> nowhere
! ESC[m
\ No newline at end of file
--- 1 ----
! l -> nowhere
diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc
index a077482..ee9b417 100755
--- a/tests/misc/ls-misc
+++ b/tests/misc/ls-misc
@@ -185,6 +185,35 @@ my @Tests =
restore_ls_colors; }},
],
+ # Test for a bug fixed after coreutils-8.2.
+ ['sl-dangle2', '-o --color=always l',
+ {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
+ {OUT => "l -> nowhere\n"},
+ {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
+ push_ls_colors('ln=target')
+ }},
+ {POST => sub {unlink 'l' or die "l: $!\n";
+ restore_ls_colors; }},
+ ],
+ ['sl-dangle3', '-o --color=always l',
+ {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
+ {OUT => "$e\e[40ml$e -> \e[34mnowhere$e\n\e[m"},
+ {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
+ push_ls_colors('ln=target:or=40:mi=34:')
+ }},
+ {POST => sub {unlink 'l' or die "l: $!\n";
+ restore_ls_colors; }},
+ ],
+ ['sl-dangle4', '-o --color=always l',
+ {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
+ {OUT => "$e\e[36ml$e -> \e[35mnowhere$e\n\e[m"},
+ {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
+ push_ls_colors('ln=34:mi=35:or=36:')
+ }},
+ {POST => sub {unlink 'l' or die "l: $!\n";
+ restore_ls_colors; }},
+ ],
+
# 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.
--
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
signature.asc
Description: OpenPGP digital signature