Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: printf and POSIX compliance



On Tue, Feb 04, 2003 at 07:26:11PM +0100, DervishD wrote:
> > http://www.opengroup.org/onlinepubs/007904975/utilities/printf.html
> > that, according to POSIX:
> 
>     That is Single Unix Specification, not POSIX, am I wrong?

I must confess I've not understood all of this imbroglio of
obscure specifications, but had the rough idea this SUS was a
step forward after POSIX. Well, it's also an IEEE (or maybe Open
Group registered at IEEE???) document and it's publicly
available.

> > 3- In addition to the escape sequences shown in the Base
> 
>     Oh, additional sequences, not POSIX ones. Ok, then :)

No, you misunderstood that point. Read at:
http://www.opengroup.org/onlinepubs/007904975/utilities/printf.html
These are additional sequences over those defined at:
http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap05.html

> > Note that neither bash nor GNU printf behave better.
> 
[...]
>     BTW, as far as I know, zsh has not a printf builtin.

I was actually speaking of printf builtin in zsh developpement
series (4.1.1-dev-x), aka "print -f"

zsh ChangeLog:

  2001-10-05  Oliver Kiddle  <opk@xxxxxxx>

        * 15851, 15948: Src/builtin.c, Doc/Zsh/builtins.yo: add printf
        builtin with basic POSIX functionality


Actually, the only portable (as far as I know) way to display my
first name with any printf (and ascii chars only) is:

printf '%b' 'St\0351phane'

printf 'St\351phane'
will break GNU and zsh ones (not bash)

printf 'St\0351phane'
will break POSIX (or whatever standard is used in recent unices)
ones (such as HPUX's one) (not bash, GNU nor zsh). I don't know
about ksh93's one.

So, that doesn't really matter if zsh printf adopts one syntax
or another, but it may be wise to pick the one that is more
likely to eventually become standard one day. Maybe the bash
behavior (\351 and \0351 both expanding to é) is the least
worst...

-- 
Stéphane



Messages sorted by: Reverse Date, Date, Thread, Author