047cb3303c
Functions can now be correctly redefined and unset in subshell environments (such as ( ... ), $(command substitutions), etc). Before this fix, attempts to do this were silently ignored (!!!), causing the wrong code (i.e.: the function by the same name from the parent shell environment) to be executed. Redefining and unsetting functions within "shared" command substitutions of the form '${ ...; }' is also fixed. Prior discussion: https://github.com/att/ast/issues/73 src/cmd/ksh93/sh/parse.c: - A fix from George Koelher (URL above). He writes: | The parser can set t->comnamp to the wrong function. | Suppose that the shell has executed | foo() { echo WRONG; } | and is now parsing | (foo() { echo ok; } && foo) | The parser was setting t->comnamp to the wrong foo. [This | fix] doesn't set t->comnamp unless it was a builtin. Now the | subshell can't call t->comnamp, so it looks for foo and finds | the ok foo in the subshell's function tree. src/cmd/ksh93/bltins/typeset.c: - Unsetting functions in a virtual/non-forked subshell still doesn't work: nv_open() fails to find the function. To work around this problem, make 'unset -f' fork the subshell into its own process with sh_subfork(). - The workaround exposed another bug: if we unset a function in a subshell tree that overrode a function by the same name in the main shell, then nv_delete() exposes the function from the main shell scope. Since 'unset -f' now always forks a subshell, the fix is to simply walk though troot's parent views and delete any such zombie functions as well. (Without this, the 4 'more fun' tests in tests/subshell.sh fail.) src/cmd/ksh93/sh/subshell.c: sh_subfuntree(): - Fix function (re)definitions and unsetting in "shared" command substitutions of the form '${ commandlist; }' (i.e.: if sp->shp->subshare is true). Though internally this is a weird form of virtual subshell, the manual page says it does not execute in a subshell (meaning, all changes must survive it), so a subshell function tree must not be created for these. src/cmd/ksh93/tests/subshell.sh: - Add regression tests related to these bugfixes. Test unsetting and redefining a function in all three forms of virtual subshell. (cherry picked from commit dde387825ab1bbd9f2eafc5dc38d5fd0bf9c3652) |
||
---|---|---|
bin | ||
docs | ||
lib/package | ||
src | ||
.gitignore | ||
LICENSE.md | ||
NEWS | ||
README.md | ||
TODO |
KornShell 93u+m
This repository is used to develop bugfixes to the last stable release (93u+ 2012-08-01) of ksh93, formerly developed by AT&T Software Technology (AST). The sources in this repository were forked from the Github AST repository which is no longer under active development.
To see what's fixed, see NEWS and click on commit messages for full details.
To see what's left to fix, see TODO.
Policy
- No new features. Bug fixes only.
- No major rewrites. No refactoring code that is not fully understood.
- No changes in documented behaviour, except if required for compliance with the POSIX shell language standard which David Korn intended for ksh to follow.
- No 100% bug compatibility. Broken and undocumented behaviour gets fixed.
- No bureaucracy, no formalities. Just fix it, or report it: create issues, send pull requests. Every interested party is invited to contribute.
- To help increase everyone's understanding of this code base, fixes and significant changes should be fully documented in commit messages.
Why?
Between 2017 and 2020 there was an ultimately unsuccessful attempt to breathe new life into the KornShell by extensively refactoring the last unstable AST beta version (93v-). While that ksh2020 branch is now abandoned and still has many critical bugs, it also had a lot of bugs fixed. More importantly, the AST issue tracker now contains a lot of documentation on how to fix those bugs, which makes it possible to backport many of them to the last stable release instead.
In February 2020, having concluded the AST 93v- beta was too broken to base new work on, others decided to start a new fork based on the last stable 93u+ 2012-08-01 release. Unfortunately, as of June 2020, the new ksh-community organisation is yet to see any significant activity four months after its bootstrapping. I hope that will change; I am ready to join efforts with them at any time, as well as anyone else who wants to contribute.
The last stable ksh93 release from 2012 is the least buggy release currently available, but it still has many serious bugs. So it is well past time to start fixing those bugs, leave the rest of the code alone, and get an improved release out there.
Build
After cloning this repo, cd to the top directory of it and run:
./bin/package make
If you have trouble or want to tune the binaries, you may pass additional compiler and linker flags by appending it to the command shown above. E.g.:
./bin/package make \
SHELL=/bin/bash CCFLAGS="-xc99 -D_XPG6 -m64 -xO4" LDFLAGS="-m64"
For more information run
bin/package help
Many other commands in this repo self-document via the --help
, --man
and
--html
options; those that do have no separate manual page.
Test
After compiling, you can run the regression tests. Start by reading the information printed by:
./bin/shtests --man