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

Re: printf and POSIX compliance



On 4 Feb, you wrote:
> Hello all, and thank you for the very good job
> 
> I read at
> http://www.opengroup.org/onlinepubs/007904975/utilities/printf.html
> that, according to POSIX:
> 
> 3- In addition to the escape sequences shown in the Base
>    Definitions volume of IEEE Std 1003.1-2001, Chapter 5, File
>    Format Notation ( '\\' , '\a' , '\b' , '\f' , '\n' , '\r' ,
>    '\t' , '\v' ), "\ddd" , where ddd is a one, two, or
>    three-digit octal number, shall be written as a byte with the
>    numeric value specified by the octal number.
> 
> So
> 
> printf '\377\0377' | od -c
> 
> should return:
> 0000000 377 037   7
> 0000003

Okay, that's what printf(3) and ksh93's printf do.

> zsh man pages says that sames sequences as for echo are
> recognized. That's not what POSIX requires.

It uses the same code as for echo and $'...' and doing otherwise would
seem a bit unpleasant to me. That said, it seems to be what ksh93 does.
In ksh, $'...' and printf work that way while print does something
different.

Note also that the behaviour of \c should probably be to cancel further
output in printf but it isn't (again because I used the same function
as is used by echo).

It's an easy enough thing to change though. Should I? And what should
it do for print and for posix quotes?

Oliver

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.



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