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 #23 received at 65659 <at> debbugs.gnu.org (full text, mbox):

From: Emanuele Torre <torreemanuele6 <at> gmail.com>
To: Eric Blake <eblake <at> redhat.com>
Cc: 65659 <at> debbugs.gnu.org, bug-bash <at> gnu.org, austin-group-l <at> opengroup.org,
 Chet Ramey <chet.ramey <at> case.edu>
Subject: Re: bug#65659: RFC: changing printf(1) behavior on %b
Date: Thu, 31 Aug 2023 23:11:39 +0200
On Thu, Aug 31, 2023 at 03:02:22PM -0500, Eric Blake wrote:
> On Thu, Aug 31, 2023 at 03:10:58PM -0400, Chet Ramey wrote:
> > Why not standardize another character, like %B? I suppose I'll have to look
> > at the etherpad for the discussion. I think that came up on the mailing
> > list, but I can't remember the details.
> 
> Yes, https://austingroupbugs.net/view.php?id=1771 has a good
> discussion of the various ideas.
> 
> %B is out for the same reason as %b: although the current C2x draft
> wording says that %<capital> is reserved for implementation use, other
> than [AEFGX] which already have a history of use by C (as it was, when
> C99 added %A, that caused problems for some folks), it goes on to
> _highly_ encourage any implementation that adds %b for "0b0" binary
> output also add %B for "0B0" binary output (to match the x/X
> dichotomy).  Burning %B to retain the old behavior while repurposing
> %b to output lower-case binary values is thus a non-starter, while
> burning %#s (which C says is undefined) felt nicer.

Also note that, in ksh93, %B is already used for something else.
It interprets its argument as a variable name, and dereferences it:
`printf %B PWD' is similar to `printf %s "$PWD"' (assuming PWD is a
string variable).

o/
 emanuele6




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.