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:
parent
090b65e79b
commit
d087b031f0
6 changed files with 47 additions and 4 deletions
|
|
@ -250,5 +250,18 @@ actual=$(printf %q $'1\x[11]1')
|
|||
[[ $actual == "$expect" ]] || err_exit 'shell-quoting: hex bytes not protected from subsequent hex-like chars' \
|
||||
"(expected $expect; got $actual)"
|
||||
|
||||
# ======
|
||||
# https://github.com/ksh93/ksh/issues/290
|
||||
var=dummy
|
||||
exp='{}'
|
||||
got=$(eval 'echo ${var:+'\''{}'\''}' 2>&1)
|
||||
[[ $got == "$exp" ]] || err_exit "Single quotes misparsed in expansion operator string (1)" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
unset var
|
||||
exp='}'
|
||||
got=$(eval 'echo ${var:-'\''}'\''}' 2>&1)
|
||||
[[ $got == "$exp" ]] || err_exit "Single quotes misparsed in expansion operator string (2)" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue