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

[bug] Incorrect output from printf '{%-5.s}' 123456789



It appears that zsh doesn't handle the precision specifier for %s correctly in
the printf builtin:

% builtin printf '{%-5.s}' 123456789
{123456789}
% command printf '{%-5.s}' 123456789
{     }
% bash -c "builtin printf '{%-5.s}' 123456789"
{     }
% dash -c "printf '{%-5.s}' 123456789"
{     }

man 3 printf says that for %s "if the precision is given as just '.', the
precision is taken to be zero.". Since the precision specifier for %s gives the
maximum number of characters to print, with a precision of zero the effect of
%-5.s should be to right-pad the empty string with 5 spaces. But instead zsh
ignores this and prints the full string.



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