Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> writes: > +# This function is equivalent to > +# > +# __gitcomp "$(git xxx --git-completion-helper) ..." > +# > +# except that the output is cached. Accept 1-3 arguments: > +# 1: the git command to execute, this is also the cache key > +# 2: extra options to be added on top (e.g. negative forms) > +# 3: options to be excluded The options="${options/ $i / }" substitution in a loop is cute. The third argument to this helper is an IFS separated list of regular expressions to match options that we do not want to see in the completion, so __gitcomp_builtin foo '' '--a[^ ]*' presumably would exclude all options whose names begin with 'a' ;-). > + if [ -z "$options" ]; then > + # leading and trailing spaces are significant to make > + # option removal work correctly. > + options=" $(__git ${cmd/_/ } --git-completion-helper) $incl " > + for i in $excl; do > + options="${options/ $i / }" > + done > + eval "$var=\"$options\"" > + fi > + > + __gitcomp "$options" > +} > + > # Variation of __gitcomp_nl () that appends to the existing list of > # completion candidates, COMPREPLY. > __gitcomp_nl_append ()