From: Junio C Hamano <gitster@pobox•com>
To: Tony Finch <dot@dotat•at>
Cc: git@vger•kernel.org
Subject: Re: [PATCH] git-prompt: preserve command exit status
Date: Mon, 22 Dec 2014 09:19:40 -0800 [thread overview]
Message-ID: <xmqqa92fbo0j.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <alpine.LSU.2.00.1412221429490.28934@hermes-1.csi.cam.ac.uk> (Tony Finch's message of "Mon, 22 Dec 2014 14:30:03 +0000")
Tony Finch <dot@dotat•at> writes:
> Signed-off-by: Tony Finch <dot@dotat•at>
> ---
> contrib/completion/git-prompt.sh | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> index c5473dc..5fe69d0 100644
> --- a/contrib/completion/git-prompt.sh
> +++ b/contrib/completion/git-prompt.sh
> @@ -288,6 +288,7 @@ __git_eread ()
> # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
> __git_ps1 ()
> {
> + local exit=$?
> local pcmode=no
> local detached=no
> local ps1pc_start='\u@\h:\w '
> @@ -511,4 +512,7 @@ __git_ps1 ()
> else
> printf -- "$printf_format" "$gitstring"
> fi
> +
> + # preserve exit status
> + return $exit
> }
Hmmmm. I thought "The patch trivially makes sense! Why didn't
anybody notice this before?!?", but then noticed that I never
suffered from an obvious consequence from the current lack of the
exit-code-preserving:
: gitster git.git/master; echo "<$PS1>"
<: \h \W$(__git_ps1 "/%s"); >
: gitster git.git/master; false
: gitster git.git/master; echo $?
1
And it does not seem that it is needed, at least for my use
pattern:
: gitster git.git/master; ps1func () { echo "What Now: "; exit 8; }
: gitster git.git/master; PS1='$(ps1func)'
What Now: echo $?
0
What Now: (exit 6)
What Now: echo $?
6
Also it does not seem that it is needed for the other style to use
PROMPT_COMMAND:
: gitster git.git/master; sh
$ . contrib/completion/git-prompt.sh
$ PROMPT_COMMAND='__git_ps1 "\h \W" "; "'
gitster git.git (master); (exit 13)
gitster git.git (master); echo $?
13
gitster git.git (master); true
gitster git.git (master); echo $?
0
So, what are you fixing? In other words, please describe how it
fails in the log message.
Puzzled...
next prev parent reply other threads:[~2014-12-22 17:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-22 14:30 [PATCH] git-prompt: preserve command exit status Tony Finch
2014-12-22 17:19 ` Junio C Hamano [this message]
2014-12-22 18:09 ` [PATCH v2] git-prompt: preserve value of $? inside shell prompt Tony Finch
2014-12-22 19:58 ` Junio C Hamano
2014-12-22 22:18 ` Tony Finch
2015-01-13 23:57 ` SZEDER Gábor
2015-01-14 10:05 ` Tony Finch
2015-01-14 10:06 ` [PATCH] git-prompt: preserve value of $? in all cases Tony Finch
2015-01-14 12:10 ` SZEDER Gábor
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=xmqqa92fbo0j.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=dot@dotat$(echo .)at \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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