1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-24 15:04:13 +00:00
cde/src/cmd/ksh93/tests
Martijn Dekker 8e97419b0b Fix ${.sh.subshell} counter to actually count level of subshells
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)
2020-06-12 01:45:16 +02:00
..
alias.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
append.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
arith.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
arrays.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
arrays2.sh Fix 47 typos in user-facing help and error messages 2020-06-12 01:45:12 +02:00
attributes.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
basic.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
bracket.sh tests/bracket.sh: don't test r/w perms as root; fix typos 2020-06-12 01:45:15 +02:00
builtins.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
case.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
comvar.sh Fix 80 typos in comments 2020-06-12 01:45:12 +02:00
comvario.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
coprocess.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
cubetype.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
enum.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
exit.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
expand.sh Fix 47 typos in user-facing help and error messages 2020-06-12 01:45:12 +02:00
functions.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
glob.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
grep.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
heredoc.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
io.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
leaks.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
locale.sh tests/locale.sh: fix test that depended on 'od' whitespace output 2020-06-12 01:45:13 +02:00
math.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
nameref.sh fix 24 more typos found with the help of codespell 2020-06-12 01:45:15 +02:00
namespace.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
options.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
path.sh tests/path.sh: if root, skip tests involving unreadable scripts 2020-06-12 01:45:14 +02:00
pointtype.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
pty.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
quoting.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
quoting2.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
readcsv.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
recttype.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
restricted.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
return.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
select.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
shtests shtests: report signal when a test crashes 2020-06-12 01:45:15 +02:00
sigchld.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
signal.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
statics.sh fix 24 more typos found with the help of codespell 2020-06-12 01:45:15 +02:00
subshell.sh regress tests: remove use of unportable direct paths to commands 2020-06-12 01:45:15 +02:00
substring.sh Fix 47 typos in user-facing help and error messages 2020-06-12 01:45:12 +02:00
tilde.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
timetype.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
treemove.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
types.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
variables.sh Fix ${.sh.subshell} counter to actually count level of subshells 2020-06-12 01:45:16 +02:00
vartree1.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
vartree2.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00