threads / discuss / 34523

Incompatible '+=' syntax in git-completion.bash

Subject: Incompatible '+=' syntax in git-completion.bash

## tl;dr

2 messages between Jul 24, 2013 and Jul 24, 2013.

replies: 1people: 2as markdown or json

Matthew Wang· Jul 24, 2013, 01:54 UTC · lore
Hi there,

I noticed a change in commit 734b2f0 on contrib/completion/git-completion.bash which reverted a syntax fix for '+=' syntax [1], the syntax does not work for bash < 3.1. As far as I know, bash 3.0.x is still widely used on some old servers, could someone add the fix back again?

Thanks, Matt

[1] https://github.com/git/git/commit/734b2f0532d847a9f566183982f83ddea8d8d197#commitcomment-3664571
Junio C Hamano· Jul 24, 2013, 15:31 UTC · re: Matthew Wang · lore

Re: Incompatible '+=' syntax in git-completion.bash

Matthew Wang <mattwyl@gmail.com> writes:
Show 5 quoted lines
> I noticed a change in commit 734b2f0 on
> contrib/completion/git-completion.bash which reverted a syntax fix for
> '+=' syntax [1], the syntax does not work for bash < 3.1.  As far as I
> know, bash 3.0.x is still widely used on some old servers, could
> someone add the fix back again?

Does anybody know of a reason why a[$#a+1]=$c notation should not be used for zsh? If there isn't, I think we should cherry-pick

    50c5885e (git-completion.bash: replace zsh notation that breaks
    bash 3.X, 2013-01-18)

by Brandon on top of 'master' or on 6bf931a5 (Merge branch 'fc/zsh-leftover-bits', 2013-06-02).

Thanks.
-- >8 --
From: Brandon Casey <drafnel@gmail.com>
Date: Fri, 18 Jan 2013 11:24:01 -0800
Subject: [PATCH] git-completion.bash: replace zsh notation that breaks bash 3.X

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>
Signed-off-by: Junio C Hamano <gitster@pobox.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..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.8.3.4-995-g2e35dd8

← back to recent threads