From: Junio C Hamano <gitster@pobox.com>
To: Brandon Casey <bcasey@nvidia.com>
Cc: <git@vger.kernel.org>, Brandon Casey <drafnel@gmail.com>,
<szeder@ira.uka.de>
Subject: Re: [PATCH 3/3] Revert "bash prompt: avoid command substitution when finalizing gitstring"
Date: Wed, 21 Aug 2013 14:47:55 -0700 [thread overview]
Message-ID: <xmqq7gfeu35g.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1377118173-23405-3-git-send-email-bcasey@nvidia.com> (Brandon Casey's message of "Wed, 21 Aug 2013 13:49:33 -0700")
Brandon Casey <bcasey@nvidia.com> writes:
> From: Brandon Casey <drafnel@gmail.com>
>
> This reverts commit 69a8141a5d81925b7e08cb228535e9ea4a7a02e3.
>
> Old Bash (3.0) which is distributed with RHEL 4.X and other ancient
> platforms that are still in wide use, does not have a printf that
> supports -v. Let's revert this patch and go back to using printf
> in the traditional way.
>
> Signed-off-by: Brandon Casey <drafnel@gmail.com>
> ---
Is this something you can detect at load-time once, store the result
in a private variable and then switch on it at runtime, something
along the lines of...
# on load...
printf -v __git_printf_supports_v -- "%s" yes >/dev/null 2>&1
...
if test "${__git_printf_supports_v}" = yes
then
printf -v gitstring -- "$printf_format" "$gitstring"
else
gitstring=$(printf -- "$printf_format" "$gitstring")
fi
> contrib/completion/git-prompt.sh | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> index a81ef5a..7698ec4 100644
> --- a/contrib/completion/git-prompt.sh
> +++ b/contrib/completion/git-prompt.sh
> @@ -433,11 +433,7 @@ __git_ps1 ()
> local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
>
> if [ $pcmode = yes ]; then
> - if [[ -n ${ZSH_VERSION-} ]]; then
> - gitstring=$(printf -- "$printf_format" "$gitstring")
> - else
> - printf -v gitstring -- "$printf_format" "$gitstring"
> - fi
> + gitstring=$(printf -- "$printf_format" "$gitstring")
> PS1="$ps1pc_start$gitstring$ps1pc_end"
> else
> printf -- "$printf_format" "$gitstring"
next prev parent reply other threads:[~2013-08-21 21:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-21 20:49 [PATCH 1/3] git-completion.bash: use correct Bash/Zsh array length syntax Brandon Casey
2013-08-21 20:49 ` [PATCH 2/3] t9902-completion.sh: old Bash still does not support array+=('') notation Brandon Casey
2013-08-21 20:49 ` [PATCH 3/3] Revert "bash prompt: avoid command substitution when finalizing gitstring" Brandon Casey
2013-08-21 21:47 ` Junio C Hamano [this message]
2013-08-21 22:08 ` Brandon Casey
2013-08-22 0:22 ` Junio C Hamano
2013-08-22 0:33 ` Brandon Casey
2013-08-22 1:17 ` [PATCH] contrib/git-prompt.sh: handle missing 'printf -v' more gracefully Brandon Casey
2013-08-22 1:39 ` Brandon Casey
2013-08-22 1:27 ` [PATCH 3/3] Revert "bash prompt: avoid command substitution when finalizing gitstring" Junio C Hamano
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=xmqq7gfeu35g.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=bcasey@nvidia.com \
--cc=drafnel@gmail.com \
--cc=git@vger.kernel.org \
--cc=szeder@ira.uka.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.