[Top][All Lists]

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

[PATCH] numfmt: Support cut style field ranges

From: Dylan Cali
Subject: [PATCH] numfmt: Support cut style field ranges
Date: Fri, 5 Sep 2014 07:26:48 -0500


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

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).

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

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?


Attachment: numfmt-field-ranges.patch
Description: Text Data

reply via email to

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