Skip to content

Commit

Permalink
completion: Allow dash as the first character for __git_ps1
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Christian Hammerl authored and Junio C Hamano committed Feb 21, 2012
1 parent 233054d commit f24a595
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit f24a595

Please sign in to comment.