On Sun, 19 Apr 2020 at 20:40, Chet Ramey <chet.ra...@case.edu> wrote: > > On 4/17/20 6:37 PM, Robert Elz wrote: > > > This happens only because of the cheap way we (and I presume you) > > implement things - in any rational scheme, it would take the precision > > chars from the source string, and then quote them.
That, or at least refuse to emit a dangling escape char. There are arguments against both. GNU Coreutils printf rejects size specifiers for %q and %b, probably for this reason. > Nobody, including POSIX, is rational, then. Chet, I don't know that POSIX attempt to make a guarantee about output being reusable as shell input at all, so I don't know that we need to fallback on POSIX as a reason to break that guarantee. I that although GNU coreutils printf doesn't exhibit this behaviour of %q (entirely rejecting size specifiers for it) ksh does exhibit this behaviour, I will make a report there. This is another candidate for shellcheck I guess, which reminds me that I forgot to submit the one for leaky named file descriptors (in contrast to numeric ones). Sam