From 7867768f4516559c129ed9eb07ae29c36a6c9367 Mon Sep 17 00:00:00 2001 From: "Tom \"Ravi\" Hale" Date: Sun, 16 Apr 2017 14:10:10 +0700 Subject: [PATCH] __git_ps1: Don't kill shell if user types `set -e` Ensure that `set +e` is in effect inside __git_ps1 to prevent any commands exiting non-zero from killing an interactive shell in which the user has run `set -e`. --- 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 97eacd7..15a0b74 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -304,6 +304,10 @@ __git_ps1 () local ps1pc_start='\u@\h:\w ' local ps1pc_end='\$ ' local printf_format=' (%s)' + # Prevent any non-zero exit statuses from killing an interactive shell in the + # case that a user types `set -e` + local -- - # Shadow shell options in $- (restored upon return) + set +e case "$#" in 2|3) pcmode=yes -- 2.11.1