Re: [PATCH] completion: add option completion for most builtin commands
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 24, 2018, 13:38 UTC
- Message-ID
- <CACsJy8CxdGXUcqP5r2u6kcjrsftO+-CrNVaFy5wv85Mm3F8pPg@mail.gmail.com>
- In-Reply-To
- <xmqqtvt8kn92.fsf@gitster-ct.c.googlers.com>
On Thu, Mar 22, 2018 at 6:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 23 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes:
>
>> +__git_main_with_parseopt_helper='
>> + blame cat-file check-attr check-ignore
>> + check-mailmap checkout-index column count-objects fast-export
>> + hash-object index-pack interpret-trailers merge-file mktree
>> + pack-objects pack-refs prune prune-packed read-tree repack
>> + send-pack show-ref stripspace symbolic-ref update-index
>> + update-ref verify-commit verify-tag write-tree
>> +'
>> +__git_complete_command() {
>> + local command="$1"
>> + local completion_func="_git_${command//-/_}"
>> + if declare -f $completion_func >/dev/null 2>/dev/null; then
>> + $completion_func
>> + elif echo $__git_main_with_parseopt_helper | git grep -w "$command" >/dev/null; then
>
> "git grep"???
>
> I imagined that you'd keep an associative shell array (we are not
> constrained by POSIX here) that can be used like so
>
> elif test -n "${__git_main_with_parseopt_helper[$command]}"; thenNope. We are not constrained by POSIX, but MacOS still runs the ancient bash 3.x while associative arrays are in 4.x
-- Duy