# [PATCH] git-completion.bash: replace zsh notation that breaks bash 3.X

6 messages from 2013-01-18 to 2013-01-18. Participants: Brandon Casey, Andreas Schwab, Junio C Hamano.
Thread: https://gitlist.dev/t/32662

## Brandon Casey, 2013-01-18 10:31

Subject: [PATCH] git-completion.bash: replace zsh notation that breaks bash 3.X
Message-ID: <1358505065-16913-1-git-send-email-drafnel@gmail.com>
URL: https://gitlist.dev/e/1358505065-16913-1-git-send-email-drafnel%40gmail.com

```
When commit d8b45314 began separating the zsh completion from the bash
completion, it introduced a zsh completion "bridge" section into the bash
completion script for zsh users to use until they migrated to the zsh
script.  The zsh '+=()' append-to-array notation prevents bash 3.00.15 on
CentOS 4.x from loading the completion script and breaks test 9902.  We can
easily work around this by using standard Bash array notation.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a4c48e1..c14e329 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2431,7 +2431,7 @@ if [[ -n ${ZSH_VERSION-} ]]; then
 				--*=*|*.) ;;
 				*) c="$c " ;;
 				esac
-				array+=("$c")
+				array[$(($#array+1))]="$c"
 			done
 			compset -P '*[=:]'
 			compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
-- 
1.8.1.1.252.gdb33759

```

## Andreas Schwab, 2013-01-18 15:02

Subject: Re: [PATCH] git-completion.bash: replace zsh notation that breaks bash 3.X
Message-ID: <m2obgmjzz0.fsf@igel.home>
URL: https://gitlist.dev/e/m2obgmjzz0.fsf%40igel.home
In-Reply-To: <1358505065-16913-1-git-send-email-drafnel@gmail.com>

```
Brandon Casey <drafnel@gmail.com> writes:

> +				array[$(($#array+1))]="$c"

You don't need $(( )) since the array index is already evaluated as an
arithmethic expression.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```

## Brandon Casey, 2013-01-18 19:07

Subject: Re: [PATCH] git-completion.bash: replace zsh notation that breaks bash 3.X
Message-ID: <CA+sFfMd6FLchoOcUpNZ3AxTLNp3qe=VjijRid4sWf-A3_w88qw@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BsFfMd6FLchoOcUpNZ3AxTLNp3qe%3DVjijRid4sWf-A3_w88qw%40mail.gmail.com
In-Reply-To: <m2obgmjzz0.fsf@igel.home>

```
On Fri, Jan 18, 2013 at 7:02 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Brandon Casey <drafnel@gmail.com> writes:
>
>> +                             array[$(($#array+1))]="$c"
>
> You don't need $(( )) since the array index is already evaluated as an
> arithmethic expression.

Ah, I didn't know that.  Thanks.

I think Junio will probably fix this up if he thinks it's worth it,
but I can resubmit if necessary.

-Brandon

```

## Junio C Hamano, 2013-01-18 19:08

Subject: Re: [PATCH] git-completion.bash: replace zsh notation that breaks bash 3.X
Message-ID: <7vr4liqpg4.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vr4liqpg4.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CA+sFfMd6FLchoOcUpNZ3AxTLNp3qe=VjijRid4sWf-A3_w88qw@mail.gmail.com>

```
Brandon Casey <drafnel@gmail.com> writes:

> On Fri, Jan 18, 2013 at 7:02 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>> Brandon Casey <drafnel@gmail.com> writes:
>>
>>> +                             array[$(($#array+1))]="$c"
>>
>> You don't need $(( )) since the array index is already evaluated as an
>> arithmethic expression.
>
> Ah, I didn't know that.  Thanks.
>
> I think Junio will probably fix this up if he thinks it's worth it,
> but I can resubmit if necessary.

Please; I do not have mental bandwidth to keep track of contrib/
material myself.

```

## Brandon Casey, 2013-01-18 19:11

Subject: Re: [PATCH] git-completion.bash: replace zsh notation that breaks bash 3.X
Message-ID: <CA+sFfMd7hurR=4n1r9RLtMYoxnM_LFH5j1McJc8+8_JumqviLg@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BsFfMd7hurR%3D4n1r9RLtMYoxnM_LFH5j1McJc8%2B8_JumqviLg%40mail.gmail.com
In-Reply-To: <7vr4liqpg4.fsf@alter.siamese.dyndns.org>

```
On Fri, Jan 18, 2013 at 11:08 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Brandon Casey <drafnel@gmail.com> writes:
>
>> On Fri, Jan 18, 2013 at 7:02 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>>> Brandon Casey <drafnel@gmail.com> writes:
>>>
>>>> +                             array[$(($#array+1))]="$c"
>>>
>>> You don't need $(( )) since the array index is already evaluated as an
>>> arithmethic expression.
>>
>> Ah, I didn't know that.  Thanks.
>>
>> I think Junio will probably fix this up if he thinks it's worth it,
>> but I can resubmit if necessary.
>
> Please; I do not have mental bandwidth to keep track of contrib/
> material myself.

No problem.

-Brandon

```

## Brandon Casey, 2013-01-18 19:24

Subject: [PATCH v2] git-completion.bash: replace zsh notation that breaks bash 3.X
Message-ID: <1358537041-29333-1-git-send-email-drafnel@gmail.com>
URL: https://gitlist.dev/e/1358537041-29333-1-git-send-email-drafnel%40gmail.com
In-Reply-To: <CA+sFfMd7hurR=4n1r9RLtMYoxnM_LFH5j1McJc8+8_JumqviLg@mail.gmail.com>

```
When commit d8b45314 began separating the zsh completion from the bash
completion, it introduced a zsh completion "bridge" section into the bash
completion script for zsh users to use until they migrated to the zsh
script.  The zsh '+=()' append-to-array notation prevents bash 3.00.15 on
CentOS 4.x from loading the completion script and breaks test 9902.  We can
easily work around this by using standard Bash array notation.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
---


On Fri, Jan 18, 2013 at 7:02 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Brandon Casey <drafnel@gmail.com> writes:
>
>> +                             array[$(($#array+1))]="$c"
>
> You don't need $(( )) since the array index is already evaluated as an
> arithmethic expression.

Fixed.

-Brandon


 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a4c48e1..2f99420 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2431,7 +2431,7 @@ if [[ -n ${ZSH_VERSION-} ]]; then
 				--*=*|*.) ;;
 				*) c="$c " ;;
 				esac
-				array+=("$c")
+				array[$#array+1]="$c"
 			done
 			compset -P '*[=:]'
 			compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
-- 
1.7.8.4


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

```
