Skip to content

Commit 487b17d

Browse files
committed
Merge branch 'tf/prompt-preserve-exit-status'
Using the exit status of the last command in the prompt, e.g. PS1='$(__git_ps1) $? ', did not work well because the helper function stomped on the exit status. * tf/prompt-preserve-exit-status: git-prompt: preserve value of $? inside shell prompt
2 parents 7938918 + eb443e3 commit 487b17d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contrib/completion/git-prompt.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ __git_eread ()
288288
# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
289289
__git_ps1 ()
290290
{
291+
local exit=$?
291292
local pcmode=no
292293
local detached=no
293294
local ps1pc_start='\u@\h:\w '
@@ -511,4 +512,7 @@ __git_ps1 ()
511512
else
512513
printf -- "$printf_format" "$gitstring"
513514
fi
515+
516+
# preserve exit status
517+
return $exit
514518
}

0 commit comments

Comments
 (0)