Recent email correspondence with @kdudka has made me think that maybe, in making POSIX compliance front and centre to development here, I've been giving insufficient consideration to the fact that there is an installed base of set-and-forget ksh93 scripts still running, which may somehow depend on old non-compliant behaviour.
In principle, I'm still thinking that anyone who needs 100% bug compatibility should stick with exactly the version they are running. However, we can restore the documented or otherwise clearly intended non-compliant behaviour as part of an option that can be turned on and off.
Other shells such as bash, mksh and yash can do set -o posix to enable POSIX compliance mode. It is worth considering adding a similar option to ksh93. ksh should probably default to POSIX mode when invoked as sh, and to "legacy" otherwise. Having the posix option off would restore behaviour such as what has been fixed in 6a49720 (edit: nah, that's just pure breakage, and completely undocumented), eeee77e (edit: done in c607c48), and maybe 36da314 (edit: nah, that was just a bug).
It would also keep the Bourne shell compatibility hack for a literal [ -t ] or test -t being interpreted as [ -t 1 ]/test -t 1. Korn hacked the parser so that only a literal [ -t ] is changed and not something like x=-t; [ "$x" ]. Still, that hack violates POSIX and should be deactivated in any new POSIX mode. (edit: done in 55f0f8c)
Let's think about this for a while before doing anything. We can talk about it in this issue's thread, and figure out a list of things that need to be switched by such an option.
Recent email correspondence with @kdudka has made me think that maybe, in making POSIX compliance front and centre to development here, I've been giving insufficient consideration to the fact that there is an installed base of set-and-forget ksh93 scripts still running, which may somehow depend on old non-compliant behaviour.
In principle, I'm still thinking that anyone who needs 100% bug compatibility should stick with exactly the version they are running. However, we can restore the documented or otherwise clearly intended non-compliant behaviour as part of an option that can be turned on and off.
Other shells such as bash, mksh and yash can do
set -o posixto enable POSIX compliance mode. It is worth considering adding a similar option to ksh93. ksh should probably default to POSIX mode when invoked as sh, and to "legacy" otherwise. Having the posix option off would restore behaviour such as what has been fixed in 6a49720 (edit: nah, that's just pure breakage, and completely undocumented), eeee77e (edit: done in c607c48), and maybe 36da314 (edit: nah, that was just a bug).It would also keep the Bourne shell compatibility hack for a literal
[ -t ]ortest -tbeing interpreted as[ -t 1 ]/test -t 1. Korn hacked the parser so that only a literal[ -t ]is changed and not something likex=-t; [ "$x" ]. Still, that hack violates POSIX and should be deactivated in any new POSIX mode. (edit: done in 55f0f8c)Let's think about this for a while before doing anything. We can talk about it in this issue's thread, and figure out a list of things that need to be switched by such an option.