Re: [PATCH v2] completion: zsh: support completion after "git -C <path>"
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 20, 2026, 21:39 UTC
- Message-ID
- <xmqqo6ewtqs8.fsf@gitster.g>
- In-Reply-To
- <CALnO6CC35iuyJpKZtkEN7fGuGK7zKd_jbebyZdKSQ1pyfOBRZA@mail.gmail.com>
"D. Ben Knoble" <ben.knoble@gmail.com> writes:
Show 10 quoted lines
>> ++ ;; >> ++ -c|--git-dir|--work-tree|--namespace) >> ++ (( i++ )) >> ++ ;; >> ++ -*) >> ++ ;; > > Yep, unlike Bash (which requires at least one command in the "list" > part between a pattern and the terminator), Zsh accepts empty actions > here.
This may be a common misconception.
It is true that a compound_list is not allowed to be empty, but POSIX.1 sh grammar [*] explicitly allows ';;' to come after ')' without a compound_list in between.
Specifically
case_item : pattern ')' linebreak DSEMI linebreak
| pattern ')' compound_list DSEMI linebreak
| '(' pattern ')' linebreak DSEMI linebreak
| '(' pattern ')' compound_list DSEMI linebreak
;where "linebreak" is a run of NEWLINE tokens or empty. So
case $foo in bar) ;; esac
is allowed.
[Footnote]
* Look for case_clause in https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html and read from there.