-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) This should fix various crashes that remain, at least: * when running a PS2 discipline at parse time * when pressing Ctrl+C on a PS2 prompt * when a special builtin within a discipline throws an error within a virtual subshell src/cmd/ksh93/sh/nvdisc.c: - In both assign() which handles .set disciplines and lookup() which handles .get disciplines, to stop errors in discipline functions from wreaking havoc: - Save, reinitialise and restore the lexer state in case the discipline is run at parse time. This happens with PS2; I'm not currently aware of other contexts but that doesn't mean there aren't any or that there won't be any. Plus, I determined by experimenting that doing this here seems to be the only way to make it work reliably. Thankfully the overhead is low. - Check the topfd redirection state and run sh_iorestore() if needed. Without this, if a special builtin with a redirection throws an error in a discipline function, its redirection(s) remain permanent. For example, 'trap --bad-option 2>/dev/null' in a PS2.get() discipline would kill standard error, including all your prompts. src/cmd/ksh93/sh/io.c: io_prompt(): - Before getting the value of the PS2 prompt, save the stack state and restore it after. This stops a PS2.get discipline function from corrupting a command substitution that the user is typing. Doing this in assign()/lookup() is ineffective, so do it here. Fixes: #347
- Loading branch information
Showing
4 changed files
with
61 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters