zsh-workers
 help / color / mirror / code / Atom feed
* printf \045 (or whatever the character code for % is)
@ 2010-12-29 21:11 Jilles Tjoelker
  2010-12-29 23:55 ` Alexey I. Froloff
  2011-01-05 17:39 ` Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Jilles Tjoelker @ 2010-12-29 21:11 UTC (permalink / raw)
  To: Zsh Hackers' List

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-06 16:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-29 21:11 printf \045 (or whatever the character code for % is) Jilles Tjoelker
2010-12-29 23:55 ` Alexey I. Froloff
2011-01-05 17:39 ` Peter Stephenson
2011-01-06  4:46   ` Bart Schaefer
2011-01-06 12:09     ` Peter Stephenson
2011-01-06 16:01       ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).