mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
Fix remaining bug in ${var:-'{}'} (re: d087b031
)
The following problems remained:
$ var=x; echo ${var:-'{}'}
x}
$ var=; echo ${var:+'{}'}
}
src/cmd/ksh93/sh/macro.c: varsub():
- Use the new ST_MOD1 state table to skip over ${var-'foo'}, etc.
instead of ST_QUOTE. In ST_MOD1 the ' is categorised as S_LIT
which causes the single quotes to be skipped over correctly.
See d087b031
for more info.
src/cmd/ksh93/tests/quoting2.sh:
- Add tests for this remaining bug.
- Make the new test xtrace-proof.
Resolves: https://github.com/ksh93/ksh/issues/290 (again)
This commit is contained in:
parent
1aec9b06dd
commit
f31e368795
4 changed files with 25 additions and 4 deletions
5
NEWS
5
NEWS
|
@ -3,6 +3,11 @@ For full details, see the git log at: https://github.com/ksh93/ksh
|
|||
|
||||
Any uppercase BUG_* names are modernish shell bug IDs.
|
||||
|
||||
2021-05-03:
|
||||
|
||||
- Completed the 2021-04-30 fix for ${var<OP>'{}'} where <OP> is '-', '+',
|
||||
':-' or ':+' by fixing a bug that caused an extra '}' to be output.
|
||||
|
||||
2021-04-30:
|
||||
|
||||
- The emacs 'ESC .' (M-.) and vi '_' commands now take shell quoting into
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
||||
#define SH_RELEASE_SVER "1.0.0-alpha" /* semantic version number: https://semver.org */
|
||||
#define SH_RELEASE_DATE "2021-04-30" /* must be in this format for $((.sh.version)) */
|
||||
#define SH_RELEASE_DATE "2021-05-03" /* must be in this format for $((.sh.version)) */
|
||||
#define SH_RELEASE_CPYR "(c) 2020-2021 Contributors to ksh " SH_RELEASE_FORK
|
||||
|
||||
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
||||
|
|
|
@ -1659,7 +1659,7 @@ retry1:
|
|||
}
|
||||
else
|
||||
{
|
||||
sh_lexskip(lp, RBRACE, 0, sh_lexstates[ST_BRACE][c]==S_MOD1 ? ST_QUOTE : ST_NESTED);
|
||||
sh_lexskip(lp, RBRACE, 0, sh_lexstates[ST_BRACE][c]==S_MOD1 ? ST_MOD1 : ST_NESTED);
|
||||
stkseek(stkp,offset);
|
||||
}
|
||||
argp=stkptr(stkp,offset);
|
||||
|
|
|
@ -254,14 +254,30 @@ actual=$(printf %q $'1\x[11]1')
|
|||
# https://github.com/ksh93/ksh/issues/290
|
||||
var=dummy
|
||||
exp='{}'
|
||||
got=$(eval 'echo ${var:+'\''{}'\''}' 2>&1)
|
||||
got=$(set +x; 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=$(set +x; 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"))"
|
||||
exp='x'
|
||||
got=$(var=x; set +x; eval 'echo ${var:-'\''{}'\''}' 2>&1)
|
||||
[[ $got == "$exp" ]] || err_exit "Single quotes misparsed in expansion operator string (3)" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
exp=''
|
||||
got=$(var=; set +x; eval 'echo ${var:+'\''{}'\''}' 2>&1)
|
||||
[[ $got == "$exp" ]] || err_exit "Single quotes misparsed in expansion operator string (4)" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
exp='{}'
|
||||
got=$(unset var; set +x; eval 'echo ${var-'\''{}'\''}' 2>&1)
|
||||
[[ $got == "$exp" ]] || err_exit "Single quotes misparsed in expansion operator string (5)" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
exp=''
|
||||
got=$(unset var; set +x; eval 'echo ${var+'\''{}'\''}' 2>&1)
|
||||
[[ $got == "$exp" ]] || err_exit "Single quotes misparsed in expansion operator string (6)" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
Loading…
Reference in a new issue