bug-bash
[Top][All Lists]
Advanced

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

Re: printf %m$ and %*m$ unimplemented in Bash, but implementated in C co


From: Lawrence Velázquez
Subject: Re: printf %m$ and %*m$ unimplemented in Bash, but implementated in C compilers
Date: Mon, 27 May 2024 21:22:55 -0400
User-agent: Cyrus-JMAP/3.11.0-alpha0-491-g033e30d24-fm-20240520.001-g033e30d2

On Mon, May 27, 2024, at 8:58 PM, porterleete wrote:
>   The man page for printf says that for integer m, %m$ lets you
> specify which argument that the conversion specification will use.
> Similarly, using *m$ instead of * in a conversion specification lets
> you specify which argument the * will pull from. This feature is
> unimplemented in Bash. I am guessing that Bash is using either the ISO
> C standard, or an older version of some mainstream compiler for printf
> or some other standard

Neither.  Bash's printf is based on the POSIX printf utility:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html

It also implements a few extensions, which are documented in the
bash man page and manual.  (IIRC there is also at least one
undocumented extension.)


> Fix:
>  Either update the documentation of what printf in bash actually does.
> If printf is using a standard for printf other than "what the biggest
> C compilers currently do", document which standard it's using or
> update it to the newest standard used by gcc and clang. If it really
> is just this one feature that's missing, add it in or document its
> absence.

The bash man page and manual already state:

        In addition to the standard printf(1) format specifications,
        printf interprets the following extensions:
        %b [...]
        %q [...]
        %Q [...]
        %(datefmt)T [...]

I guess it could be more explicit, but "the standard printf(1)
format specifications" refers to the POSIX standard for the printf
*utility*.  The C printf *function* is tangentially related but
not directly relevant.

-- 
vq



reply via email to

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