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


View this message in rfc822 format

From: Pádraig Brady <P <at> draigBrady.com>
To: Nicolas Boichat <nicolas <at> boichat.ch>, 77179 <at> debbugs.gnu.org
Subject: bug#77179: seq incorrectly(?) pads output when last parameter magnitude larger than last printed number
Date: Sat, 22 Mar 2025 19:18:40 +0000
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




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.