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

Re: [doc] "sh_word_split nothing to do with word splitting"?

Op 12-03-18 om 08:43 schreef Stephane Chazelas:
> I'd rather zsh keep it that way as a statement of resistance
> against silliness, at least until someone complains that his
> POSIX script fails when run on zsh because its arithmetic
> expansions are not split as expected.

The thing is, there are very good reasons for that silliness, and for
not resisting it in sh emulation.

In a way, POSIX is primarily descriptive, not prescriptive. It intends
to incorporate the historical practice that real-world shell
implementations have copied into the standard, so that everyone can be
compatible with it.

For the most part, that historical practice was established by AT&T
ksh88. It's mostly obsolete now but very much lives on in all the shells
that copy its behaviour.

ksh88 implemented the original shell arithmetic expansion. It subjects
those expansions to IFS field splitting.

Not emulating this in zsh's sh emulation mode will probably not cause
many scripts to fail on zsh-as-sh. However, someone could use zsh to
develop a POSIX script intended to be compatible with other shells.

And that someone might end up under the mistaken impression that it's
pointless to quote arithmetic expansions. Cue potential mysterious
breakage on non-zsh shells.

That's why I believe it's important that this is fixed in sh emulation.

> pdksh was not doing word/field splitting there and posh and
> OpenBSD sh still don't.

Then pdksh, supposedly a ksh88 clone, failed to clone ksh88 in that
aspect -- among many others.

pdksh, posh, NetBSD ksh, OpenBSD sh/ksh, and nearly all other pdksh
derivatives are all full of bugs and fatally broken when it comes to
implementing POSIX compatibility.

The only properly working pdksh derivative is mksh (and its "legacy"
even-more-POSIX companion lksh).

- M.

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