mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix syntax error detection in associative array assignments
Reproducer: $ fn=([foo_key]=foo_val [bar_key]) -ksh: [bar_key]: not found Expected output: -ksh: syntax error: `[bar_key]' unexpected As soon as one correct associative array assignment element has been processed, a subsequent one, starting with '[' but not containing ']=', is incorrectly seen as a command to execute. If a command '[bar_key]' existed on $PATH, it would have been run. src/cmd/ksh93/sh/parse.c: simple(): - In the syntax check for associative array assignments, don't just check for an initial '[' but also verify the presence of ']='. Thanks to @JohnoKing for finding this bug. Resolves: https://github.com/ksh93/ksh/issues/427
This commit is contained in:
parent
06e56251b9
commit
fbfd4d3ab8
3 changed files with 15 additions and 1 deletions
|
|
@ -1507,7 +1507,7 @@ static Shnode_t *simple(Lex_t *lexp,int flag, struct ionod *io)
|
|||
lexp->token = LBRACE;
|
||||
break;
|
||||
}
|
||||
if(associative && argp->argval[0]!='[')
|
||||
if(associative && (argp->argval[0]!='[' || !strstr(argp->argval,"]=")))
|
||||
sh_syntax(lexp);
|
||||
/* check for assignment argument */
|
||||
if((argp->argflag&ARG_ASSIGN) && assignment!=2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue