This counter is documented as follows: "The current depth for subshells and command substitution." But before this commit, the actual behaviour was that the counter was reset to zero whenever a subshell forked for any reason: a pipe, background job, running 'ulimit', redirecting stdout in a command substitution, and more. This behaviour was: 1. Not consistent with the documentation. Non-forked (a.k.a. virtual) subshells are an internal implementation detail which scripts should not have to be concerned with. The manual page doesn't mention them at all. 2. Inherently broken. Since a subshell may fork for any number of reasons, even mid-run, and those reasons may change with bugfixes and further development, scripts have never actually been able to rely on the value of ${.sh.subshell}. So, this commit fixes the counter to count the levels of all subshells, both virtual and forked. src/cmd/ksh93/sh/xec.c: _sh_fork(): - Increase ${.sh.subshell} whenever we fork. src/cmd/ksh93/sh/subshell.c: - sh_subfork(): * Fix comment to properly explain what it does. It doesn't "create" a subshell, it forks off an existing virtual subshell. * Don't zero ${.sh.subshell}. Instead, since sh_fork() increases it but we're forking an existing subshell, undo the increase. - sh_subshell(): * Remove 'int16_t subshell' variable. It was unnecessary and mostly unused. It was also the wrong type: it was assigned the value from shp->subshell which is of type short. * Increase and decrease the level of virtual subshells and ${.sh.subshell} independently. src/cmd/ksh93/tests/variables.sh: - Add regression tests for ${.sh.subshell} in virtual and forked subshells of several kinds: comsub, parentheses, pipe, bg job. - Undo wrong error test count fix from 04b4aef0. (cherry picked from commit a0e0e29e7e0dbf21e4b3958ae02bde6665fb2696) |
||
---|---|---|
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