1. %q is GNU- and zsh-specific
It's in GNU /usr/bin/printf and bash/zsh builtins, but busybox printf and dash's builtin error out and it's not in the FreeBSD, OpenBSD, NetBSD, DragonFly BSD, macOS, or Solaris printf manpages.
2. printf(1) isn't just "available in most systems", POSIX requires it:
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html
3. printf actually is a builtin under busybox, dash, bash, and zsh… but only zsh makes `which` a builtin:
% which printf
printf: shell built-in command
@yohanandiamond I found a long Unix & Linux Stack Exchange answer which explains what a mess things are with echo and extensions to printf and why it's generally a good idea to stick to the POSIX-specifed subset of printf:
@ssokolow Thanks for the clarification, this answers pretty much every question I had related to the topic :P
@yohanandiamond
AFAICT, %q is specific to the CLI printf, so things like dash and BusyBox probably error out because their printf(1) just hands off to glibc's printf(3).
It wouldn't surprise me if the same implementation decision is also at play in all the non-GNU, non-Zsh stuff on the BSDs, macOS, and Solaris.
(After all, it *is* kind of nonsensical and counter-intuitive to have two separate implementations of printf formatting in the same userland rather than just putting %q into glibc.)