-
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 wrong syntax error upon process substitution after redirection
Grammatically, redirections may occur anywhere within a command line and are removed after processing them, whereas a process substitution (<(commandlist) or >(commandlist)) is replaced by a file name which should be treated as just another simple word. So the following should not be a syntax error: $ cat </dev/null <(true) -ksh: syntax error: `)' unexpected $ cat </dev/null >(true) -ksh: syntax error: `)' unexpected $ cat >/dev/null <(true) -ksh: syntax error: `)' unexpected $ cat >/dev/null >(true) -ksh: syntax error: `)' unexpected This bug is in every ksh93 version. The problem is in the parser (parse.c). The process substitution is misparsed as a redirection due to inout() recursively parsing multiple redirections without recognising process substitutions. inout() is mistaking '<(' for '<' and '>(' for '>', which explains the incorrect syntax error. This also causes the following to fail to detect a syntax error: $ cat >&1 <(README.md [the contents of README.md are shown] ...and other syntax errors detected in the wrong spot, for example: $ { true; } <(echo wrong) -ksh: syntax error: `wrong' unexpected which should be: -ksh: syntax error: `<(' unexpected src/cmd/ksh93/sh/parse.c: - Add global inout_found_procsub flag. - inout(): On encountering a process substitution, set this flag and return, otherwise clear the flag. - simple(): After calling inout(), check this flag and, if set, jump back to where process substitutions are parsed. Resolves: #418
- Loading branch information
Showing
4 changed files
with
44 additions
and
1 deletion.
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