Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2
uname output: Linux portercomp3 6.9.1 #1-NixOS SMP PREEMPT_DYNAMIC Fri
May 17 10:18:09 UTC 2024 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.2
Patch Level: 26
Release Status: release

  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, and therefore do not know where to find more
complete documentation for it.

The following program runs without warnings or errors in clang, and in
gcc only warns on -Wpedantic with "warning: ISO C does not support %n$
operand number formats [-Wformat=]":
#include <stdio.h>
int main(void) {
    printf("%2$*1$d", 10,100);
    return 0;

The following line of bash script errors in bash:
`printf '%2$*1$d' 10 100`
bash: printf: `$': invalid format character

 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

Reply via email to