Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
Hello PƔdraig,
On 07/12/2015 02:33 PM, PƔdraig Brady wrote:
<...>
Hmm. Shouldn't we treat the above like field 1 and all fields up to 2 inclusive?
Similarly shouldn't we allow ranges like:
$ echo 1 2 3 4 5 | numfmt --field -2,4- --to-unit=1000 --round=down
0 0 3 0 0
$ echo 1 2 3 4 5 | numfmt --field -2,-4 --to-unit=1000 --round=down
0 0 0 0 5
Attached is a reworked patch. In it, I've copied the 'set_fields' function from
cut almost verbatim.
now numfmt accepts the same variations as 'cut --fields=LIST' (including the
examples you mentioned above),
with the addition that '--field=-' means 'all fields'.
To illustrate, attached are excerpts of 'set_fields' from cut.c and numfmt.c, a
diff between them will show the minor changes.
comments welcomed,
- assaf