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-11 20:42:05 +0100, Stephane Chazelas wrote:
> 2021-04-11 18:57:26 +0100, Stephane Chazelas:
> > Some non-POSIX conformances I can think of ATM:
> [...]
> 
> Another POSIX bug fixed by zsh (but which makes it non-compliant):
> 
> With multibyte characters:
> 
> $ printf '|%10s|\n' Stéphane Chazelas
> |  Stéphane|
> |  Chazelas|
> 
> POSIX requires:
> 
> | Stéphane|
> |  Chazelas|

I would think that's intentional, at least for the precision
(e.g. %.4s) in order to prevent buffer overflow.

-- 
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