#1335·sh

zsh: Support anonymous function arguments.

Author: zelchCreated May 10, 2026Updated May 31, 2026
Labelszsh

I have some shell code like:

bash
    function my-cd-rotate() {
        () {
            builtin emulate -L zsh
            while (( $#dirstack )) && ! builtin pushd -q $1 &>/dev/null; do
                builtin popd -q $1
            done
            (( $#dirstack ))
        } "$@" && reset-prompt
    }

shfmt w3.13.1 gives statements must be separated by &, ; or a newline.

You can remove the && reset-prompt and get the same result.