Re: [PATCH v3 04/42] git-completion.bash: introduce __gitcomp_builtin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 ()



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux