mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Restore namespace's parent scope when exiting due to error
Reproducer: $ namespace test { x=123; typeset -g x=456; } $ echo $x ${.test.x} 456 123 $ namespace test { typeset -Q; } arch/darwin.i386-64/bin/ksh: typeset: -Q: unknown option [usage message snipped for brevity] $ echo $x ${.test.x} 123 123 <== expected: 123 456 $ x=789 $ echo $x ${.test.x} 789 789 <== expected: 789 456 $ # look at that, we never left the namespace... When prefixing the erroneous 'typeset' with 'command', the problem does not occur. 'command' disables the properties of special built-ins such as exit on error. So, when a special built-in exits on error, the parent scope is not properly resotred. This bug exists in every ksh93 version with SHOPT_NAMESPACE so far. src/cmd/ksh93/sh/xec.c: sh_exec(): - Before entering a namespace, use sh_pushcontext and sigsetjmp to make sure we return here if sh_exit() is called, e.g. when a special builtin throws an error, to ensure the parent scope (oldnspace) is restored. Thanks to @hyenias for making me aware of this bug. Discussion: https://github.com/ksh93/ksh/issues/479#issuecomment-1140468965
This commit is contained in:
parent
8f14514661
commit
f73b8617dd
4 changed files with 28 additions and 2 deletions
5
NEWS
5
NEWS
|
@ -3,6 +3,11 @@ For full details, see the git log at: https://github.com/ksh93/ksh/tree/1.0
|
|||
|
||||
Any uppercase BUG_* names are modernish shell bug IDs.
|
||||
|
||||
2022-05-29:
|
||||
|
||||
- Fixed a bug causing an inconsistent state after a special built-in command
|
||||
threw an error within a namespace.
|
||||
|
||||
2022-05-27:
|
||||
|
||||
- Fixed a bug introduced on 2022-03-05 where 'set --default', while turning
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue