From: Junio C Hamano Date: Mon, 17 Apr 2017 04:24:58 GMT Subject: Re: [PATCH] __git_ps1: Don't kill shell if user types `set -e` Message-ID: In-Reply-To: "Tom \"Ravi\" Hale" writes: > If a user types `set -e` in an interactive shell, and is using __git_ps1 > to set > their prompt, the shell will die if the current directory isn't inside a git > repository. > > This is because `set -e` instructs the shell to exit upon a command > returning a non-zero exit status, and the following command exits with > status 128: > > repo_info="$(git rev-parse --git-dir --is-inside-git-dir \ > --is-bare-repository --is-inside-work-tree \ > --short HEAD 2>/dev/null)" Hmph. So the fix would be something like this? repo_info="$(git rev-parse --git-dir --is-inside-git-dir \ --is-bare-repository --is-inside-work-tree \ - --short HEAD 2>/dev/null)" + --short HEAD 2>/dev/null || :)" I am too afraid to ask what a user would try to achieve by doing the "set -e" thing in an interactive session. It is understandable (I am not saying I think it is necessarily a good idea) to do so in a script, but for an interactive shell?