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

sh_setenviron(): deactivate compound assignment prefix

Reproducers:

$ ksh -c 'typeset -a arr=( ( (a $(($(echo 1) + 1)) c)1))'
ksh: echo: arr[0]._AST_FEATURES=CONFORMANCE - ast UNIVERSE - ucb: cannot be an array
ksh: [1]=1: invalid variable name
$ ksh -c 'typeset -a arr=( (a $(($(echo 1) + 1)) c)1)'
ksh: echo: arr._AST_FEATURES=CONFORMANCE - ast UNIVERSE - ucb: is not an identifier
ksh: [1]=1: invalid variable name

src/cmd/ksh93/sh/name.c: sh_setenviron():
- Save and clear the current compound assignment prefix (sh.prefix)
  while assigning to the _AST_FEATURES variable.
This commit is contained in:
Martijn Dekker 2022-06-22 17:02:25 +01:00
parent 4d50b69cbd
commit d8dc2a1d81
4 changed files with 19 additions and 1 deletions

View file

@ -706,5 +706,14 @@ EOF
"$SHELL" -c "$compound_array"
) || err_exit 'unsetting an array turned into a compound variable fails'
# ======
# before 2022-06-22, this resulted in:
# ksh: echo: arr[0]._AST_FEATURES=CONFORMANCE - ast UNIVERSE - ucb: cannot be an array
# ksh: [1]=1: invalid variable name
got=$(set +x; eval 'typeset -a arr=( ( (a $(($(echo 1) + 1)) c)1))' 2>&1; typeset -p arr)
exp='typeset -a arr=(((a 2 c) 1) )'
[[ $got == "$exp" ]] || err_exit "'echo' environment messed up by compound assignment" \
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
# ======
exit $((Errors<125?Errors:125))