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

Re: printf %s in UTF-8 is not POSIX-compliant



On 2008-03-05 10:41:48 +0000, Peter Stephenson wrote:
> In particular, "emulate sh" is the nearest we have to bash emulation
> and bash users are likely to expect multibyte characters to work
> naturally.

I don't know what you mean by "naturally", but zsh currently behaves
differently from bash in sh emulation:

vin:~> sh
sh-3.1$ printf ".%2s.\n" é
.é.
sh-3.1$ exit
vin:~> zsh -f
vin% emulate sh
vin% printf ".%2s.\n" é
. é.
vin% 

And the behavior of bash, when run as sh, will not change. So,
I expect zsh to do the same in sh emulation mode.

Note that bash still outputs .é. (POSIX behavior) when run as bash,
but this may change.

> Is it time to introduce a separate "bash" emulation (meaning smart,
> interactive shell not necessarily 100% POSIX compatible) and
> document that "sh" emulation is aimed at POSIX compatibility?
> "emulate bash" already works but is treated the same way as "emulate sh".

Perhaps it should have the same differences as bash with and without
POSIX mode. I don't know what the best behavior is about the startup
files. From the bash man page:

  [...] When invoked as sh, bash enters posix mode after the startup
  files are read.

  When bash is started in posix mode, as with the --posix command line
  option, it follows the POSIX standard for startup files. [...]

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



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