Subject: bug#13555: printf ignores length modifier

From: Paul Eggert <[email-masked]>
Date: Sat, 26 Jan 2013 08:37:42 -0800

On 01/26/2013 01:41 AM, Marcel Böhme wrote:
> $old/printf "%hi\n" 0xFFFF
> -1
> $printf "%hi\n" 0xFFFF
> 65535

None of these length modifiers are specified by POSIX,
so we're talking about what it's more useful for printf
to do, rather than whether this is a violation of
a standard.  coreutils printf should agree
with Bash printf, and Bash printf ignores the modifiers,
so if we change coreutils we should change Bash too.

I suppose that 'printf' could change its behavior, and
use (say) 32-bit int for '%li' on a x86 but 64-bit int
on x86-64, thus exposing the native machine widths to
the user.  However, for shell scripts I expect that more
people prefer portability to exposing the machine widths,
so the current behavior is better.