Skip to content

zsh: support special parameters @ and * in parameter expansion with subscripts using braces #1299

Closed

Description

@LangLangBart
# Echoes the last argument passed to it
fntest() { echo "${@[-1]}"; }; fntest foo bar baz
# baz

❌ Fails to parse when indexing @ or * with a subscript and braces

./shfmt --language-dialect zsh <<<'echo "${@[-1]}"'
# <standard input>:1:10: cannot index a special parameter name

./shfmt --language-dialect zsh <<<'echo "${*[-1]}"'
# <standard input>:1:10: cannot index a special parameter name

✅ The short (braceless) form already works

./shfmt --language-dialect zsh <<<'echo $@[-1]'
# echo $@[-1]
./shfmt --language-dialect zsh <<<'echo $*[-1]'
# echo $*[-1]

Activity

  1. added a commit that references this issue on Mar 22, 2026
    3413d5a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址