[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug#65659: RFC: changing printf(1) behavior on %b
From: |
Emanuele Torre |
Subject: |
Re: bug#65659: RFC: changing printf(1) behavior on %b |
Date: |
Thu, 31 Aug 2023 23:11:39 +0200 |
User-agent: |
Mutt/2.2.11 (2023-08-18) |
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