Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[bug] Incorrect output from printf '{%-5.s}' 123456789
- X-seq: zsh-workers 38305
- From: Ryan Wilson <ryan@xxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: [bug] Incorrect output from printf '{%-5.s}' 123456789
- Date: Thu, 21 Apr 2016 17:21:41 -0500
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=zoho; d=enosys.org; h=date:from:to:message-id:subject:mime-version:content-type:user-agent; b=joc+/JhXJkGL1/BAinKOQGtqBF0+B/vFofIrKyG/KHgm6Js24CttzeKKo+koQA0fHzvp5IZ7/dmw UAkEST4ecj3V9TP2QzHAdE6v5nJ3q9Or9IBLtvcvZOn+MLNmSTydJTJ5k+7NLXx11XhqHE1KGCr7 VI8whQkW9G9W5n/fNNg=
- 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
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