Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
printf \045 (or whatever the character code for % is)
- X-seq: zsh-workers 28551
- From: Jilles Tjoelker <jilles@xxxxxxxx>
- To: Zsh Hackers' List <zsh-workers@xxxxxxx>
- Subject: printf \045 (or whatever the character code for % is)
- Date: Wed, 29 Dec 2010 22:11:55 +0100
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
While trying to run the FreeBSD sh testsuite with zsh, various tests
fail because the printf builtin interprets \045 (ASCII) as a percent
sign introducing a format specification instead of a literal percent
sign. The \045 arises because I create all 255 non-zero byte values via
octal escapes.
POSIX's description assumes that the backslash escapes and format
specifications are processed in one pass and simply says that an octal
escape sequence shall write the corresponding byte. If they are separate
passes the backslash escape removal step needs to know about percent
signs.
The sequences \% and \x25 are not specified and there seems little
reason to use them.
Input:
printf '\045\n'
Expected result:
Succeeds and prints "%".
Actual result:
Fails and prints error message "printf: %\n: invalid directive".
Input:
printf '\045d.%d\n' 4 5
Expected result:
%d.4
%d.5
Actual result:
4.5
--
Jilles Tjoelker
Messages sorted by:
Reverse Date,
Date,
Thread,
Author