Re: [PATCH] bash-completion: don't add quoted space for ZSH (fix regression)
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 15, 2012, 02:29 UTC
- Message-ID
- <7vsjjhwvdy.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1326567336-2173-1-git-send-email-Matthieu.Moy@imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
Show 13 quoted lines
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index b0062ba..488e1f4 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -534,6 +534,12 @@ __gitcomp_nl ()
> fi
> fi
>
> + # ZSH would quote the trailing space added with -S. bash users
> + # will appreciate the extra space to compensate the use of -o nospace.
> + if [ -n "${ZSH_VERSION-}" ] && [ "$suffix" = " " ]; then
> + suffix=""
> + fiThis should take care of the SP set by the beginning of the helper function
local cur_="$cur" suffix=" "
but is that the right thing to do if suffix came from "$4"?
As far as I can see, "$4" is used to append "." in very limited cases, and nobody explicitly passes SP as "$4" when calling this, so it may be easier to read if you moved this before that "if we have 3 or more args, use the fourth one as the suffix" block, i.e. something like this?
contrib/completion/git-completion.bash | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index b0062ba..4ad75ed 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -525,7 +525,10 @@ __gitcomp () __gitcomp_nl () { local s=$'\n' IFS=' '$'\t'$'\n' - local cur_="$cur" suffix=" " + local cur_="$cur" + # Because we use '-o nospace' under bash, we need to compensate + # for it by appending SP after completed word ourselves. + local suffix="${BASH_VERSION+ }" if [ $# -gt 2 ]; then cur_="$3"