-
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.
Fix certain syntax errors not being recorded in history
For the following types of syntax error, the command line is not recorded in the shell history for retrieval and correction: $ a[]=12 -ksh: syntax error at line 1: `[]' empty subscript $ function foo $bad { :; } -ksh: syntax error at line 1: invalid reference list $ echo $(( 1 << 8 ) ) -ksh: syntax error at line 1: `<<8' here-document not contained within command substitution Up-arrow will not work to get the above command lines back. It's also odd that these report a line number (1) though we're working on the interactive command line and other syntax errors do not report a line number, e.g.: $ ) -ksh: syntax error: `)' unexpected Analysis: Syntax errors are normally thrown via a call to sh_syntax(), which does the I/O stream flushing and closing necessary to ensure that the command line gets added to the history before calling errormsg(). But the above three problematic errors call errormsg() directly. The fix is to refactor sh_syntax() to handle these errors properly and call sh_syntax() when these occur. src/cmd/ksh93/sh/lex.c, src/cmd/ksh93/sh/parse.c: - Add 'special' argument to sh_syntax() to handle the three cases above. A value of zero is a regular syntax error and 1-3 are the special messages above. - Construct the error message in parts using the sh.strbuf Sfio string buffer. This fixes the cosmetic 'at line 1' problem on interactive shells. src/cmd/ksh93/data/{keywords,lexstates}.c, src/cmd/ksh93/include/{shlex,lexstates}.h: - Refactor and rename the syntax error-related messages to make the above changes possible. - Group them all together in lexstates.{c,h} for clarity. Resolves: #775
- Loading branch information
Showing
8 changed files
with
108 additions
and
104 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
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
Oops, something went wrong.