Re: [PATCH v2] completion: zsh: support completion after "git -C <path>"

Junio C Hamano <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
"D. Ben Knoble" <[email protected]> writes:

>>      ++                         ;;
>>      ++                 -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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.