Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regression caused by ${var:-'{}'} fix (re: f31e368)
The regression is: quoting.sh[189]: expansion of "{q:+'}" not correct when q unset The failure was that, for unset q, "${q:+'}q${q:+'}" yielded empty and not 'q'. This is because the single quotes within the double quotes were erroneously parsed as meaningful. The originally used ST_QUOTE state table (see data/lexstates.c), where no quote character has any special meaning, was for avoiding this problem. The newly introduced ST_MOD1 state table is a copy of ST_QUOTE except the ' has been given its special meaning back. We need this to fix #290, but only for unquoted expansions. So we need to go back to using ST_QUOTE if the string is quoted (mp->quote) and we're not parsing a substitution that uses patterns where quotes are significant (newops, ST_MOD2), i.e., only for old-style ST_MOD1 operators. src/cmd/ksh93/sh/macro.c: varsub(): - When the ${var<OP>string} expansion is quoted, and of an old (S_MOD1) type, then use the ST_QUOTE state table to skip over it instead of the new ST_MOD1 one.
- Loading branch information