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 047cb3303c Fix redefining & unsetting functions in subshells (BUG_FNSUBSH)
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)
2020-06-12 01:45:14 +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 Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
bracket.sh Fix 'test -t 1' in $(command substitutions) 2020-06-12 01:45:13 +02:00
builtins.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +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 Version: 2012-08-01-master 2016-01-11 15:54:23 -05: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 Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
glob.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
grep.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
heredoc.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
io.sh Fix truncating of files with <>;file combined with <#pattern 2020-06-12 01:45:14 +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 Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
namespace.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
options.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +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 Fix 47 typos in user-facing help and error messages 2020-06-12 01:45:12 +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 Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +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: don't require specifying .sh extension for test script 2020-06-12 01:45:14 +02:00
sigchld.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
signal.sh Regression test suite: get rid of unportable 'mktemp -dt' 2020-06-12 01:45:13 +02:00
statics.sh Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
subshell.sh Fix redefining & unsetting functions in subshells (BUG_FNSUBSH) 2020-06-12 01:45:14 +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 tests/variables.sh: minor fix in failure error msg 2020-06-12 01:45:14 +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