git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Matthieu Moy <Matthieu.Moy@imag.fr>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] bash-completion: don't add quoted space for ZSH (fix regression)
Date: Sat, 14 Jan 2012 18:29:45 -0800	[thread overview]
Message-ID: <7vsjjhwvdy.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1326567336-2173-1-git-send-email-Matthieu.Moy@imag.fr> (Matthieu Moy's message of "Sat, 14 Jan 2012 19:55:36 +0100")

Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> 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=""
> +	fi

This 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"

  reply	other threads:[~2012-01-15  2:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-12 11:52 Zsh completion regression Stefan Haller
2012-01-12 14:56 ` Matthieu Moy
2012-01-14 13:23   ` SZEDER Gábor
2012-01-14 14:32     ` Matthieu Moy
2012-01-14 15:20       ` SZEDER Gábor
2012-01-14 18:55         ` [PATCH] bash-completion: don't add quoted space for ZSH (fix regression) Matthieu Moy
2012-01-15  2:29           ` Junio C Hamano [this message]
2012-01-16 11:49             ` Matthieu Moy
2012-01-16 22:47               ` Junio C Hamano
2012-01-17 12:21                 ` Matthieu Moy
2012-01-17 18:46                   ` Junio C Hamano
2012-01-17 19:18           ` Felipe Contreras
2012-01-17 20:03             ` Felipe Contreras
2012-01-17 20:11               ` Junio C Hamano
2012-01-17 23:04                 ` Felipe Contreras
2012-01-17 23:42                   ` Junio C Hamano
2012-01-18  8:16                     ` Matthieu Moy
2012-01-25  1:39                       ` Felipe Contreras
2012-01-25  4:06                         ` Junio C Hamano
2012-01-14 21:36         ` Zsh completion regression Stefan Haller
2012-01-14 21:36     ` Stefan Haller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vsjjhwvdy.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Matthieu.Moy@imag.fr \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).