mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 11:42:21 +00:00
Correctly exit from namespace on error (re: f73b8617
)
The referenced commit introduced at least one bug: EXIT traps were not triggered if a special builtin threw an error in a namespace that is within a virtual subshell. src/cmd/ksh93/sh/xec.c: sh_exec(): TNSPACE: - When an error occurs, siglongjmp to the previous saved environment; it is not correct to sh_exit directly. src/cmd/ksh93/tests/namespace.sh: - Remove the forkign workaround and the TODO where I incorrectly blamed this problem on the virtual subshell mechanism.
This commit is contained in:
parent
ea300089a1
commit
6dbde5ec7c
2 changed files with 2 additions and 5 deletions
|
@ -2523,7 +2523,7 @@ int sh_exec(register const Shnode_t *t, int flags)
|
|||
sh_popcontext(chkp);
|
||||
enter_namespace(oldnspace);
|
||||
if(jmpval) /* error occurred */
|
||||
sh_exit(sh.exitval);
|
||||
siglongjmp(*sh.jmplist,jmpval);
|
||||
break;
|
||||
}
|
||||
#endif /* SHOPT_NAMESPACE */
|
||||
|
|
|
@ -133,11 +133,8 @@ set +o allexport
|
|||
# ======
|
||||
# A namespace's parent scope should be restored after an error occurs.
|
||||
# https://github.com/ksh93/ksh/issues/479#issuecomment-1140514159
|
||||
#
|
||||
# TODO: this test fails when run in a non-forking comsub: the trap
|
||||
# is not executed -- the zillionth bug with virtual subshells >:-/
|
||||
exp=$'123 456\n789 456'
|
||||
got=$(ulimit -t unlimited 2>/dev/null # workaround: force fork
|
||||
got=$(
|
||||
trap 'echo $x ${.test.x}; x=789; echo $x ${.test.x}' EXIT
|
||||
x=123
|
||||
namespace test
|
||||
|
|
Loading…
Reference in a new issue