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

Re: sh emulation POSIX non-conformances (printf %10s and bytes vs character)



On 2021-04-24 01:01:59 +0200, Oliver Kiddle wrote:
> Vincent Lefevre wrote:
> > On 2021-04-22 12:22:12 -0700, Bart Schaefer wrote:
> > > Someone can probably point to the rationale document, but I'm guessing
> > > this is really because of equivalence with sprintf() formats.
> >
> > Some file formats have fields with a byte-size limit. Providing
> > more than this limit could have unexpected effects. One may also
> > want to limit the size of generated filenames (see NAME_MAX).
> 
> And for every one time that someone needs something like that, there
> are a zillion cases where people just want to line up output neatly in
> columns and are thwarted. More likely, this was just standards people
> insisting on exactly matching the C printf().

And even for that, this is currently buggy (at least under Debian)
with double-width characters. Try:

  printf "|%3s|\n" a 🍸

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




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