[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] numfmt: Support cut style field ranges
From: |
Pádraig Brady |
Subject: |
Re: [PATCH] numfmt: Support cut style field ranges |
Date: |
Fri, 05 Sep 2014 14:08:17 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
On 09/05/2014 01:26 PM, Dylan Cali wrote:
> Hello,
>
> This patch enhances numfmt to support the same field range specifiers
> that cut supports.
>
> That is:
> --field N (a single field)
> --field N-M (a field range N through M)
> --field N- (field N and all the fields after it)
> --field -M (the first field up to and including M)
>
> Multiple range specifiers can be combined with commas:
> --field N1,M1,N2-M2,N3 ... etc
>
> I've also added support for '*' to indicate all fields, as well as an
> explicit --all-fields option:
> --field \* OR --all-fields
>
> So instead of doing this:
> df | numfmt --header --field 2 --to=si \
> | numfmt --header --field 3 --to=si \
> | numfmt --header --field 4 --to=si
>
> You can now do this:
> df | numfmt --header --field 2-4 --to=si
Very nice work. This feature looks useful to add.
> There was a TODO about changing the default to processing all fields,
> and I originally made this change. After thinking about it I wasn't
> sure if this was the right thing to do, so I've left the default as
> field 1 for now (and added the all-field option/specifier instead).
It's probably best to be explicit for all fields.
I dislike the * since it clashes with shell globbing,
and the separate --all-field option looks like overkill.
How about: --field=-
I.E. there is no start or end field => all fields.
> I've added a complete set of unit tests for the new functionality, and
> I've done my best to follow the guidelines in HACKING, so please let
> me know if I missed anything.
>
> In addition to the attached patch you can also fetch the associated
> feature branch from:
> git fetch address@hidden:calid/coreutils.git
> numfmt-field-ranges:numfmt-field-ranges
Nice to see that being used
> Please note that there are a couple new gnulib modules added in
> bootstrap.conf, so if building in the git repo you will need to run
> ./bootstrap again. Annoyingly the new gnulib files generate warnings
> that cause the default make to fail, so I had to build with make
> CFLAGS=-Wno-error. I guess this is a bug in gnulib?
Can you report those to address@hidden
For a change of this size, you'll need to assign copyright.
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=doc/Copyright/request-assign.future;hb=HEAD
thanks!
Pádraig.