GNU bug report logs - #65659
RFC: changing printf(1) behavior on %b

Previous Next

Package: coreutils;

Reported by: Eric Blake <eblake <at> redhat.com>

Date: Thu, 31 Aug 2023 15:37:02 UTC

Severity: normal

Full log


Message #20 received at 65659 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Eric Blake <eblake <at> redhat.com>, coreutils <at> gnu.org
Cc: 65659 <at> debbugs.gnu.org
Subject: Re: [PATCH] printf: add %#s alias to %b
Date: Thu, 31 Aug 2023 21:48:09 +0100
[Message part 1 (text/plain, inline)]
On 31/08/2023 19:31, Eric Blake wrote:
> POSIX Issue 8 will be obsoleting %b (escape sequence interpolation) so
> that future Issue 9 can change to having %b (binary literal output)
> that aligns with C2x.  But since escape interpolation may still remain
> useful, POSIX suggested %#s (which is undefined in all versions of C)
> as a possible alias for the older %b behavior.
> 
> * src/printf.c (print_formatted, usage): Support %#s as an alias
> for %b, in order to open doors to future repurposing of %b to
> binary output while still allowing access to its old behavior.
> * doc/coreutils.texi (printf invocation): Document it.
> * NEWS: Likewise.
> * tests/printf/printf-quote.sh: Add unit test coverage.

Patch looks good thanks.
I'd add in the attached test addition.

As for compat, I notice that existing coreutils will reject %#s,
while bash 5.2.15, ksh 1.0.4, dash 0.5.12 will treat as %s.

cheers,
Pádraig
[printf-esc-test.patch (text/x-patch, attachment)]

This bug report was last modified 1 year and 341 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.