mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
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)
|
||
|---|---|---|
| .. | ||
| alias.sh | ||
| append.sh | ||
| arith.sh | ||
| arrays.sh | ||
| arrays2.sh | ||
| attributes.sh | ||
| basic.sh | ||
| bracket.sh | ||
| builtins.sh | ||
| case.sh | ||
| comvar.sh | ||
| comvario.sh | ||
| coprocess.sh | ||
| cubetype.sh | ||
| enum.sh | ||
| exit.sh | ||
| expand.sh | ||
| functions.sh | ||
| glob.sh | ||
| grep.sh | ||
| heredoc.sh | ||
| io.sh | ||
| leaks.sh | ||
| locale.sh | ||
| math.sh | ||
| nameref.sh | ||
| namespace.sh | ||
| options.sh | ||
| path.sh | ||
| pointtype.sh | ||
| pty.sh | ||
| quoting.sh | ||
| quoting2.sh | ||
| readcsv.sh | ||
| recttype.sh | ||
| restricted.sh | ||
| return.sh | ||
| select.sh | ||
| shtests | ||
| sigchld.sh | ||
| signal.sh | ||
| statics.sh | ||
| subshell.sh | ||
| substring.sh | ||
| tilde.sh | ||
| timetype.sh | ||
| treemove.sh | ||
| types.sh | ||
| variables.sh | ||
| vartree1.sh | ||
| vartree2.sh | ||