Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve fix for parentheses in param expansions (re: 5ed9ffd)
The fix was incomplete: expansions using '?' (${var?w(ord}, ${var:?wo)rd}) still did not tolerate parentheses in the word as regular characters. It was also possible to simplify the fix by making use of the ST_BRACE (sh_lexstate7[]) state table. See data/lexstates.c and include/lexstates.h. src/cmd/ksh93/sh/lex.c: sh_lex(): case S_MOD1: - The previous fix tested for modifier operator characters : - + = as part of the S_MOD2 case, though they are defined as S_MOD1 in the ST_BRACE state table. It only worked because of the fallthrough. And it turns out the S_MOD1 case already had a similar fix, though incomplete. The new fix effectively cancelled the old one out as any S_MOD1 character eventually led to 'continue'. So it can be simplified by removing most of that code, without causing any change in behaviour. Only the mode change to the ST_QUOTE state table followed by 'continue' is necessary. This also fixes it for the '?' operator as that is also defined as S_MOD1 in the ST_BRACE state table. src/cmd/ksh93/sh/macro.c: - When skipping a ${...} expansion using sh_lexskip(), use the ST_QUOTE state table if the character c is an S_MOD1 modifier operator character. This makes it consistent with the S_MOD1 handling in sh_lex(). src/cmd/ksh93/tests/variables.sh: - Update regression tests to include ? and :? operators.
- Loading branch information