1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix single quotes in expansion operator string (re: 5ed9ffd6)

The referenced commit introduced the following bug:

> The closing quote does not appear to be registering during the
> parse of the following:
>
>	echo ${var:+'{}'}
>
> Within a script, this will result in:
>
>	syntax error at line 1: `'' unmatched

src/cmd/ksh93/data/lexstates.c,
src/cmd/ksh93/include/lexstates.h:
- Add new ST_MOD1 state table that is a copy of ST_QUOTE, but adds
  a special meaning (ST_LIT) for the single quote (position 39).

src/cmd/ksh93/sh/lex.c: sh_lex():
- For parameter expansion operators with old-style quoting
  (S_MOD1), use the new ST_MOD1 state table instead of ST_QUOTE.
  This causes single quotes within them to be processed properly.

src/cmd/ksh93/tests/quoting2.sh:
- Add tests.

Thanks to @gkamat for the bug report.
Resolves: https://github.com/ksh93/ksh/issues/290
This commit is contained in:
Martijn Dekker 2021-04-30 05:10:04 +01:00
parent 090b65e79b
commit d087b031f0
6 changed files with 47 additions and 4 deletions

View file

@ -992,7 +992,7 @@ int sh_lex(Lex_t* lp)
mode = ST_NESTED;
continue;
case S_MOD1:
mode = ST_QUOTE;
mode = ST_MOD1;
continue;
case S_MOD2:
#if SHOPT_KIA