git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Hammerl <info@christian-hammerl.de>
To: git@vger.kernel.org, gitster@pobox.com
Cc: Christian Hammerl <info@christian-hammerl.de>
Subject: [PATCH] completion: Allow dash as the first character for __git_ps1
Date: Mon, 20 Feb 2012 13:17:53 +0100	[thread overview]
Message-ID: <1329740273-5580-1-git-send-email-info@christian-hammerl.de> (raw)

If the argument for `__git_ps1` begins with a dash, `printf` tries to
interpret it as an option which results in an error message.
The problem is solved by adding '--' before the argument to tell
`printf` to not interpret the following argument as an option.
Adding '--' directly to the argument does not help because the argument
is enclosed by double quotes.

Signed-off-by: Christian Hammerl <info@christian-hammerl.de>
---
 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 91c7acb..61ff152 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -313,7 +313,7 @@ __git_ps1 ()
 		fi
 
 		local f="$w$i$s$u"
-		printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
+		printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
 	fi
 }
 
-- 
1.7.9

             reply	other threads:[~2012-02-20 12:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-20 12:17 Christian Hammerl [this message]
2012-02-21 20:40 ` [PATCH] completion: Allow dash as the first character for __git_ps1 Junio C Hamano
2012-02-21 20:49   ` Christian Hammerl

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=1329740273-5580-1-git-send-email-info@christian-hammerl.de \
    --to=info@christian-hammerl.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).