Subject: [bug] Incorrect output from printf '{%-5.s}' 123456789
From: Ryan Wilson <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Thu, 21 Apr 2016 17:21:41 -0500
List-Id: Zsh Workers List <zsh-workers.zsh.org>

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.