[Top][All Lists]

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

Re: About printf %2$s (Was: Coordination on standardizing gettext() in f

From: Joerg Schilling
Subject: Re: About printf %2$s (Was: Coordination on standardizing gettext() in future POSIX)
Date: Mon, 3 Feb 2020 11:43:38 +0100
User-agent: Heirloom mailx 12.5 7/5/10

Stephane Chazelas <address@hidden> wrote:

> 2020-01-24 15:14:48 +0100, Joerg Schilling:

> >     printf "Hello World %2$s %1$s\\n"  1 2
> [...]
> > mksh                a ksh88 clone
> [...]
> ksh88 had no printf builtin.

OK, this is a mstake that frequently happens because most shells have a builtin 

> You might have been mislead by Solaris' /usr/xpg4/bin/sh

I believe that Oracle Solaris 11 still uses ksh88, as it is harder to make 
ksh93 POSIX compliant than to work with the ksh88 variant that has already been 

> On Solaris 11,
> $ /usr/xpg4/bin/sh -c 'type printf'
> printf is a shell builtin

This does not apply to OpenSolaris, but on OpenSolaris, this was closed source 
as ksh88 is not available under OSS license.

This also does not apply to Oracle Solaris 11.3, so where did you test?

Could you run "whatwhell" with this shell please?

> mksh has no printf builtin either

I know but I was confused.

> AFAIK, the printf utility is a POSIX invention (ksh93 release
> notes do mention the POSIX origin), possibly inspired by
> research Unix 10th edition which had a printf utility (but not
> %b for instance) possibly from as far back as

I believe that %b was a POSIX invention.

Svr4 had already a printf(1) in 1988, but this was a 10-liner that did just 
call printf(3) and thus could only handle strings.

> 1986 (if we're to beleive the timestamp of printf.c at
> https://www.tuhs.org/Archive/Distributions/Research/Dan_Cross_v10/v10src.tar.bz2
> $ tar tvf v10src.tar.bz2 cmd/printf.c
> -rw-rw-r-- root/root      3621 1986-07-29 20:40 cmd/printf.c

This is more than Svr4 had in 1988.

> I don't know where the %2$x format in printf(3) comes from.

Well, from my private history memory, I have in mind that Sun introduced it
in the 1980s, when the basics for gettext(3) have been created. So this must 
have been no later than for SunOS-4.0. I believe, there was a related talk on 
a Sun User Group meeting that time with examples for printing date strings.

It was in SVr4 from the beginning and since this was in printf(3) on Svr4, it 
also applies to early printf(1) in Svr4.


 EMail:address@hidden                    (home) Jörg Schilling D-13353 Berlin
    address@hidden (work) Blog: http://schily.blogspot.com/
 URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'

reply via email to

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