Jim Meyering wrote: > Pádraig Brady wrote: >> Subject: [PATCH] ls: allow disabling colors on all file types >> > Thanks for doing this. > However, with that change, the ls/no-cap test now fails: > (on Fedora 11, configured with libcap-devel.x86_64) > > make check -C tests TESTS=ls/no-cap VERBOSE=yes
Oops, that test was skipped on my system. I needed: sudo yum install libcap-devel I must look at warning or at least documenting these optional libs to get full coverage. I switched the other tests to call is_colored() last as that's probably faster for all other cases, and I switched this one for consistency. But as noted in http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commit;h=f3f1ccfd that order was on purpose for performance reasons. I'll push the attached. sorry, Pádraig. p.s. for my own reference here is another ls slow down I found: http://lists.gnu.org/archive/html/bug-coreutils/2009-04/msg00036.html
>From 8c92bb3441c628fe87ccf4a946b1c8b14cb0a0d2 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com> Date: Tue, 22 Sep 2009 10:06:49 +0100 Subject: [PATCH] ls: fix a performance regression * src/ls.c (print_color_indicator): This reinstates commit f3f1ccfd, 21-10-2008, "ls: make it possible to disable file capabilities checking" which was inadvertently reverted with commit 3a169f4c, 14-09-2009, "ls: handle disabling of colors consistently ...". --- src/ls.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/ls.c b/src/ls.c index 2fb5282..859d7c4 100644 --- a/src/ls.c +++ b/src/ls.c @@ -4126,7 +4126,8 @@ print_color_indicator (const char *name, mode_t mode, int linkok, type = C_SETUID; else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID)) type = C_SETGID; - else if (has_capability (name) && is_colored (C_CAP)) + /* has_capability() called second for performance. */ + else if (is_colored (C_CAP) && has_capability (name)) type = C_CAP; else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC)) type = C_EXEC; -- 1.6.2.5