help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Information about the format construct for printf


From: Koichi Murase
Subject: Re: Information about the format construct for printf
Date: Fri, 24 Mar 2023 09:39:01 +0900

2023年3月24日(金) 9:09 Greg Wooledge <greg@wooledge.org>:
> On Thu, Mar 23, 2023 at 07:32:51PM -0400, Lawrence Velázquez wrote:
> > On Thu, Mar 23, 2023, at 7:25 PM, Lawrence Velázquez wrote:
> > > On Thu, Mar 23, 2023, at 6:41 PM, uzibalqa wrote:
> > >> I could not find any information about the format construct for printf.
> > >>
> > >> Particularly for the not so straightforward  %*s  and  %-*s
> > >
> > > Run "man 3 printf".
> >
> > Pardon me, itchy "Send" finger.  printf(3) is the C function;
> > I meant "man 1 printf".
>
> All of the above, and more.
>
> Bash's printf implements all of the POSIX printf(1) stuff, plus some
> bash extensions.
>
> POSIX printf(1) implements most of printf(3) plus a few POSIX extensions.

To further complicate matters, "most of printf(3)" is not so evident
for programmers not familiar with the typical printf formatting. The
POSIX printf(3) specifies extensions such as numbered arguments. The
POSIX printf(1) format is actually defined based on XBD 5 which is
independent of the POSIX printf(3) format. One can basically think
most of the C printf formats are supported by the POSIX printf(1) and
thus by Bash, but `man 3 printf' in my system Fedora doesn't seem to
be explicit about which part is the C standard and which part is the
extension.

Also, technically, `man 1 printf' and `man 3 printf' might contain
extra stuff about system-specific extensions that Bash doesn't
support. Finally, one needs to reference the POSIX standard (as Bash
Reference Manual says, ``In addition to the standard printf(1)
formats''):

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap05.html#tag_05



reply via email to

[Prev in Thread] Current Thread [Next in Thread]