GNU bug report logs - #73068
printf: please implement POSIX:2024 argument reordering

Previous Next

Package: coreutils;

Reported by: Bruno Haible <bruno <at> clisp.org>

Date: Fri, 6 Sep 2024 14:07:01 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Pádraig Brady <P <at> draigBrady.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#73068: closed (printf: please implement POSIX:2024 argument
 reordering)
Date: Thu, 12 Sep 2024 16:18:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 12 Sep 2024 17:15:56 +0100
with message-id <ab4120b1-14fe-4d7a-a149-4a414f13729f <at> draigBrady.com>
and subject line Re: bug#73068: printf: please implement POSIX:2024 argument reordering
has caused the debbugs.gnu.org bug report #73068,
regarding printf: please implement POSIX:2024 argument reordering
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
73068: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73068
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Bruno Haible <bruno <at> clisp.org>
To: bug-coreutils <at> gnu.org
Subject: printf: please implement POSIX:2024 argument reordering
Date: Fri, 06 Sep 2024 16:06:34 +0200
Hi,

POSIX:2024 specifies that printf(1) should support numbered conversion
specifications:
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/printf.html
https://austingroupbugs.net/view.php?id=1592

Could this support please be added to GNU coreutils? As of coreutils 9.5,
I still get:

  $ /usr/bin/printf 'abc%2$sdef%1$sxxx\n' 1 2
  abc/usr/bin/printf: %2$: invalid conversion specification

Rationale: It was pointed out in https://austingroupbugs.net/view.php?id=1592
that these four statements do all the same thing:

1) pid=$$; eval_gettext "Running as process number \$pid."; echo
2) printf_gettext "Running as process number %d." $$; echo
3) printf "`gettext 'Running as process number %d.'`" $$; echo
4) printf $(gettext 'Running as process number %d.') $$; echo

The first one has the drawback that it requires the programmer to
add backslashes to their format strings.

The second one has the drawback that it requires a 'printf_gettext'
program (that does not yet exist).

The third and fourth one (suggested by Jörg Schilling, IIRC) feel more
natural to a shell script programmer. However, they require that
printf supports numbered arguments. In the first time, we would use
a shorthand
  $printf
where (on most GNU systems) printf='/usr/bin/printf', until bash, dash,
etc. support it as well.

The long-term goal is to be able to change the GNU gettext documentation
https://www.gnu.org/software/gettext/manual/html_node/sh.html
to list:
  "
   Formatting with positions
     printf
  "

Bruno





[Message part 3 (message/rfc822, inline)]
From: Pádraig Brady <P <at> draigBrady.com>
To: Bruno Haible <bruno <at> clisp.org>, 73068-done <at> debbugs.gnu.org
Subject: Re: bug#73068: printf: please implement POSIX:2024 argument reordering
Date: Thu, 12 Sep 2024 17:15:56 +0100
[Message part 4 (text/plain, inline)]
On 09/09/2024 19:30, Pádraig Brady wrote:
> On 06/09/2024 15:06, Bruno Haible wrote:
>> Hi,
>>
>> POSIX:2024 specifies that printf(1) should support numbered conversion
>> specifications:
>> https://pubs.opengroup.org/onlinepubs/9799919799/utilities/printf.html
>> https://austingroupbugs.net/view.php?id=1592
>>
>> Could this support please be added to GNU coreutils? As of coreutils 9.5,
>> I still get:
>>
>>     $ /usr/bin/printf 'abc%2$sdef%1$sxxx\n' 1 2
>>     abc/usr/bin/printf: %2$: invalid conversion specification
> 
> 
> This make sense to implement.
> I see ksh and FreeBSD at least, already have.
> I'll have a look at doing this.

I'll apply the attached sometime tomorrow.

Marking this as done.

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

This bug report was last modified 252 days ago.

Previous Next


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