zsh: multiple parameter subscripts fail to parse
Author: w2w2-2Created Jul 19, 2026Updated Jul 23, 2026
Labelszsh
The following valid Zsh syntax fails to parse:
var=(foo)
echo ${var[1][2]}$ shfmt --version
v3.13.2-0.20260718060058-20744fb2d3e9
$ printf '%s\n' 'var=(foo)' 'echo ${var[1][2]}' | shfmt -ln=zsh
<standard input>:2:14: not a valid parameter expansion operator: `[`Zsh accepts the same input and prints o.
See Zsh docs: Parameter subscripting, which uses ${var[1][2]} as an example.
Source: mvdan/sh