git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] completion: Allow dash as the first character for __git_ps1

From
Christian Hammerl <info@christian-hammerl.de>
Date
Feb 20, 2012, 12:17 UTC
Message-ID
<1329740273-5580-1-git-send-email-info@christian-hammerl.de>

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
Next: Junio C Hamano
Message 1 of 3 in “completion: Allow dash as the first character for __git_ps1”
  1. completion: Allow dash as the first character for __git_ps1Christian Hammerl, Feb 20, 2012
  2. Junio C HamanoFeb 21, 2012
  3. Christian HammerlFeb 21, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.