On 22/03/2025 12:36, Nicolas Boichat wrote:
Hi,
Version: seq (GNU coreutils) 9.6; OS: Archlinux, x86-64
When adding `-w` parameter, we want numbers to be padded with leading 0s,
e.g. this looks correct:
$ seq -w 0 5 10
00
05
10
However, the behaviour is perhaps incorrect when the last printed number
magnitude is lower than the last parameter, e.g:
$ seq -w 0 6 10
00
06
would probably be more correct with this output:
0
6
The manual makes no promise about this ("Print all numbers with the same
width, by padding with leading zeros"), but it's still a bit odd to add a
superfluous 0.
Also, it is especially confusing because, on the other hand, the precision
of the last parameter is ignored, as if it was just a bound that played no
role in formatting:
$ seq 0 5 10.00001
0
5
10
While
$ seq 0.0000 5 10
0.0000
5.0000
10.0000
Side note, a solution would also need to make sure that this still works:
$ seq -w 0 5 12
00
05
10
Yes we could do better here,though there are many edge cases as you've noted.
I suspect though that -w currently suffices for the
vast majority of cases it's needed for.
thanks,
Pádraig