GNU bug report logs - #77179
seq incorrectly(?) pads output when last parameter magnitude larger than last printed number

Previous Next

Package: coreutils;

Reported by: Nicolas Boichat <nicolas <at> boichat.ch>

Date: Sat, 22 Mar 2025 14:58:03 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Boichat <nicolas <at> boichat.ch>
To: bug-coreutils <at> gnu.org
Subject: seq incorrectly(?) pads output when last parameter magnitude larger
 than last printed number
Date: Sat, 22 Mar 2025 13:36:13 +0100
[Message part 1 (text/plain, inline)]
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

Thanks,
[Message part 2 (text/html, inline)]

This bug report was last modified 89 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.