mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix regression caused by ${var:-'{}'} fix (re: f31e3687)
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.
This commit is contained in:
parent
af6a32d14f
commit
5ed4c71fca
1 changed files with 6 additions and 1 deletions
|
|
@ -1659,7 +1659,12 @@ retry1:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sh_lexskip(lp, RBRACE, 0, sh_lexstates[ST_BRACE][c]==S_MOD1 ? ST_MOD1 : ST_NESTED);
|
int state;
|
||||||
|
if(sh_lexstates[ST_BRACE][c]==S_MOD1)
|
||||||
|
state = mp->quote ? ST_QUOTE : ST_MOD1;
|
||||||
|
else
|
||||||
|
state = ST_NESTED;
|
||||||
|
sh_lexskip(lp, RBRACE, 0, state);
|
||||||
stkseek(stkp,offset);
|
stkseek(stkp,offset);
|
||||||
}
|
}
|
||||||
argp=stkptr(stkp,offset);
|
argp=stkptr(stkp,offset);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue