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

Re: printf shortcomings



Micah Elliott wrote:
> I was looking at `printf(3)` and also this lovely reference
> (http://www.pixelbeat.org/programming/gcc/format_specs.html) and
> noticed that the "locale thousands grouping" flag (') doesn't appear
> to be supported by Zsh's builtin printf. I don't have an important
> need for this today, but noticing that it could be pretty useful.

That is a reference for the GNU libc printf. The thousand grouping flag
is by no means standard. Zsh's printf largely uses the system printf
underneath, so it isn't completely trivial to support GNU specific flags
portably (keep in mind that lots of flags can be combined so it isn't
just a case of sticking a character in before every third digit). We
could pass through the ' so that it only works where supported by the
system printf but we'd need to be sure it doesn't have any nasty side
effects on some system.

If you do zmodload zsh/langinfo, you can get the thousand separator from
$langinfo[THOUSEP] so if you ever do need the feature, it may be
possible to implement it using that.

Oliver



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