On 12/19/2014 07:46 AM, Maarten Billemont wrote:

> Is there a particular reason why bash's built-in printf does not support
> this format modifier?

Because POSIX does not require it to.  printf(1) is only required to
have a subset of printf(3) functionality:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap05.html#tag_05

That subset does not include $ reordering.

>  Does bash re-implement printf or does it use the
> Standard C Library's printf?  (If the former; why?)

A combination - it MUST parse the string itself (because POSIX requires
printf(1) to understand %b, but %b is not part of printf(3)), but then
calls into the system's printf family as appropriate.  And you'd be
shocked at how many libc have bugs of one form or another in their
printf(3) (even glibc's printf could cause a core dump when using %A on
certain long double bit values, until earlier this year).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Reply via email to