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

printf \045 (or whatever the character code for % is)

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

The sequences \% and \x25 are not specified and there seems little
reason to use them.

printf '\045\n'
Expected result:
Succeeds and prints "%".
Actual result:
Fails and prints error message "printf: %\n: invalid directive".

printf '\045d.%d\n' 4 5
Expected result:
Actual result:

Jilles Tjoelker

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