Re: [PATCH v4 2/2] Use the new functions to get the current cword.
- From
SZEDER Gábor <szeder@ira.uka.de>
- Date
- Dec 2, 2010, 22:36 UTC
- Message-ID
- <20101202223601.GA3577@neumann>
- In-Reply-To
- <1291236582-28603-3-git-send-email-peter@avirtualhome.com>
Hi,
Here are my nits I mentioned yesterday.
On Wed, Dec 01, 2010 at 03:49:42PM -0500, Peter van der Does wrote:
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash > index 0036e8b..f915e1f 100755 > --- a/contrib/completion/git-completion.bash > +++ b/contrib/completion/git-completion.bash
Show 8 quoted lines
> @@ -1064,9 +1073,10 @@ __git_find_on_cmdline ()
>
> __git_has_doubledash ()
> {
> - local c=1
> - while [ $c -lt $COMP_CWORD ]; do
> - if [ "--" = "${COMP_WORDS[c]}" ]; then
> + local c=1, words cwordNo comma, and ...
> + _get_comp_words_by_ref words cword > + while [ $c -lt $cwords ]; do
... that should be $cword in the condition, without the s at the end. These two typos caused some weird behaviors when completing long options for commands understanding the '--' option-path separator, e.g. git diff --<TAB<TAB>.
Show 6 quoted lines
> @@ -1775,7 +1814,7 @@ _git_notes ()
> prune,*)
> ;;
> *)
> - case "${COMP_WORDS[COMP_CWORD-1]}" in
> + case "${prev}" inShow 6 quoted lines
> @@ -2615,7 +2670,7 @@ _git_tag ()
> c=$((++c))
> done
>
> - case "${COMP_WORDS[COMP_CWORD-1]}" in
> + case "${prev}" inNo {} are needed around prev.Show 9 quoted lines
> @@ -2639,15 +2694,16 @@ _git_whatchanged ()
>
> _git ()
> {
> - local i c=1 command __git_dir
> + local i c=1 command __git_dir words cword
>
> - if [[ -n ${ZSH_VERSION-} ]]; then
> + if [[ -n $ZSH_VERSION ]]; thenShow 6 quoted lines
> @@ -2690,19 +2746,20 @@ _git ()
>
> _gitk ()
> {
> - if [[ -n ${ZSH_VERSION-} ]]; then
> + if [[ -n $ZSH_VERSION ]]; thenShow 6 quoted lines
> @@ -2730,7 +2787,7 @@ complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
> || complete -o default -o nospace -F _git git.exe
> fi
>
> -if [[ -n ${ZSH_VERSION-} ]]; then
> +if [[ -n $ZSH_VERSION ]]; thenThese three changes have nothing to do with bash4 issues, and they break in 'set -u' environments, because $ZSH_VERSION is, of course, undefined in bash.
Best, Gábor