diff --git a/Src/params.c b/Src/params.c index 4910d65fe..f61374b87 100644 --- a/Src/params.c +++ b/Src/params.c @@ -6281,7 +6281,16 @@ valid_refname(char *val) if (*t != 0) { if (*t == '[') { tokenize(t = dupstring(t+1)); - t = parse_subscript(t, 0, ']'); + while ((t = parse_subscript(t, 0, ']')) && *t++ == Outbrack) { + if (*t == Inbrack) + ++t; + else + break; + } + if (t && *t) { + /* zwarn("%s: stuff after subscript: %s", val, t); */ + t = NULL; + } } else if (t[1] || !(*t == '!' || *t == '?' || *t == '$' || *t == '-' || *t == '0' || *t == '_')) { diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst index 61c2b006a..d2abdd391 100644 --- a/Test/K01nameref.ztst +++ b/Test/K01nameref.ztst @@ -350,9 +350,9 @@ F:ksh93 does not implement this either >typeset -A hash=( [y]=HIT ) unset -n ptr1 - typeset -n ptr1='not good' + typeset -n ptr1='not[2]good' 1:invalid nameref -*?*invalid variable name: not good +*?*invalid variable name: not\[2\]good unset -n ptr1 unset hash