bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH]: ls: add --user-format option for user defined format


From: Jim Meyering
Subject: Re: [PATCH]: ls: add --user-format option for user defined format
Date: Fri, 07 Nov 2008 09:39:11 +0100

Ondřej Vašík <address@hidden> wrote:

> Pádraig Brady wrote:
>> Thanks for doing that.
>> However I thought that item had been removed from the TODO:
>> http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00115.html
>> This is a large patch to do essentially what `find -printf` already does.
>
> Sorry, haven't seen that thread before.
>
> I guess there are some things which you can't do with find -printf and
> which you can do with that --user-format ls extension.
> I would say there are few reasons why to use ls --user-format instead of
> find -printf.
>
> 1) It has scalable column width (even possible to reduce width)
> 2) It has some options unavailable in findutils e.g. for SELinux
>    context handling and filemode splitting/handling.
> 3) It is based on the informations you have completed by ls - so it
>    could be considered more reliable, e.g. it could have EXACTLY
>    the same output as ls -l otherwise have.
> 4) Is more frequent to use ls than find -printf for listing files, you
>    could get colored filenames output with column.
>
> I agree that the patch is quite large, anyway what I have heard from the
> guys around me, it would be useful to have that thing in ls. I tried to
> not impact the rest of the ls code, so the changes to the main ls code
> are pretty minimal (only some counting (and even that only for
> user_format selected) and factorization of one function in
> print_long_format).

Hi Ondřej,

I wish you had mentioned your plans before starting work on that.

Please heed the warning at the top of the TODO file, especially
when considering adding options to ls.  Here it is:

    Beware: some are quite old and no longer valid.  To avoid wasting
    your time by duplicating work or by working on a task that is no
    longer pertinent, please search the mailing list and post your intent
    before embarking on a big project.

I did not remove that TODO item on a whim.

Back when I thought it might be worthwhile, I would have required a
find-compatible format string.  One thing find has, but that stat lacks,
is a complete range of date/time-formatting options.  i.e., you can
print the date-only portion of the atime:

    $ find / -maxdepth 0 -printf '%p %AF\n'
    / 2008-10-04

or print both date and time with a "T" between them:

    $ find / -maxdepth 0 -printf '%p %AFT%AT\n'
    / 2008-10-04T04:02:02.0000000000

Have you considered adding SELinux-related format directives to GNU find?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]