On 08/10/2025 07:55, Jim Meyering wrote:
On Wed, Oct 8, 2025 at 12:37 AM Pádraig Brady <[email protected]> wrote:
...
Yes I think this feature is useful. I think the standards
also mention a preference to avoid line breaks between numbers,
and so NBSP might be good to support as an option also.
So we could have an optional argument like: --suffix-space[=CHAR]
Supporting:
--suffix-space # ASCII space
--suffix-space=$'\u00A0' # Non breaking space
--suffix-space=$'\u202F' # Narrow NBSP
Maybe --suffix-separator= or even just --separator= ?
Yes that is more accurate.
BTW, originally I envisaged that --format would be central to numfmt,
and you would get the flexibility through its arguments.
However currently we take anything after the "%f" as _after_ the suffix:
$ printf '123412G 1234123G\n' |
numfmt --from=auto --to=si --field=1,2 --format=$'[%f\u00A0]'
[124T ] [ 1.3P ]
Given any string is accepted after the %f directive,
I'm not sure it's practical to change that now.
So --suffix-separator seems like the best option.
Tangentially related to this is supporting '% f' which adds a space
before positive numbers, which allows you to better left align mixed signed
numbers.
It's currently ignored and thus this looks misaligned:
$ printf '%s\n' '123412G' '-123412G' |
numfmt --from=auto --to=si --field=1,2 --format='% -5f'
124T
-124T
cheers,
Padraig