Bug
The parser's array subscript reader in parser/mod.rs stops at the first ] character without tracking nesting. For expressions like:
${names[$RANDOM % ${#names[@]}]}
the subscript is read as $RANDOM % ${#names[ — stopping at the ] inside ${#names[@]} — instead of the full $RANDOM % ${#names[@]}.
Root cause
Around line 2390 in parse_word(), the subscript reader is:
while let Some(&c) = chars.peek() {
if c == ']' {
chars.next();
break;
}
index.push(chars.next().unwrap());
}
No bracket or brace depth tracking.
Fix
Track [] bracket depth and ${} brace depth when reading subscript content, so nested expressions don't prematurely end the subscript.
Bug
The parser's array subscript reader in
parser/mod.rsstops at the first]character without tracking nesting. For expressions like:${names[$RANDOM % ${#names[@]}]}the subscript is read as
$RANDOM % ${#names[— stopping at the]inside${#names[@]}— instead of the full$RANDOM % ${#names[@]}.Root cause
Around line 2390 in
parse_word(), the subscript reader is:No bracket or brace depth tracking.
Fix
Track
[]bracket depth and${}brace depth when reading subscript content, so nested expressions don't prematurely end the subscript.