bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] printf: add %#s alias to %b


From: Eric Blake
Subject: Re: [PATCH] printf: add %#s alias to %b
Date: Thu, 31 Aug 2023 16:15:58 -0500
User-agent: NeoMutt/20230517

On Thu, Aug 31, 2023 at 04:01:17PM -0500, Rob Landley wrote:
> On 8/31/23 13: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.
> 
> I.E. you sent an RFC to that effect to the posix list earlier today, and so 
> far
> the only reply on the posix list was the bash maintainer, who said "I doubt 
> I'd
> ever remove %b, even in posix mode -- it's already been there for 25 years."

The RFC to the POSIX list was started earlier than today
(https://austingroupbugs.net/view.php?id=1771 was filed on Aug 7, not
by me; and by Aug 8 we had already identified the future conflict with
C2x %b).  But you are right that today was the first time I widened
the audience by mailing coreutils and bash (rather than just the few
developers that follow the POSIX mailing list).  There are also plans
to ask the same question of other shell developers (dash, BSD,
busybox, ...); but I figured I'd start with the people and code I know
best.

It's not hard to see why POSIX is choosing to have Issue 8 obsoleting
(not removing) %b's old semantics; in the short term, nothing about %b
changes, so your dusty-deck shell scripts will continue to work as
they have before; but you now have enough time to update your scripts.
The question is whether Issue 9 (several years down the road) will be
able to repurpose %b to mean binary literal output (only possible if
all shell authors agree that C2X compatibility is worth it), or must
instead just undocument %b altogether (shells can always provide
extensions that POSIX doesn't document - and the obvious extensions in
that case would be a shell's choice of %b with the old semantics or %b
to do binary literals).

But if POSIX _is_ able to repurpose %b (because enough shell authors
agree that binary output is more useful these days than XSI echo
compatibility), the followon question is whether there should be a
portable way to access the old functionality.  Since %#s is currently
unspecified, we are trying to guage feedback of how many
implementations are willing to add that alias now, which in turn will
affect whether Issue 9 can mandate that behavior (because everyone
liked it) or must continue to leave it undefined.

But nothing is stopping coreutils from adding %#s as an extension now,
regardless of what input other shell authors provide to the ongoing
POSIX discussion.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]