From: SZEDER Gábor Date: Wed, 09 May 2012 00:44:49 GMT Subject: [RFC PATCH 18/19] bash prompt: avoid command substitution when checking for untracked files Message-ID: <1336524290-30023-19-git-send-email-szeder@ira.uka.de> In-Reply-To: <1336524290-30023-1-git-send-email-szeder@ira.uka.de> When enabled, the bash prompt can indicate the presence of untracked files with a '%' sign. __git_ps1() checks for untracked files by running the '$(git ls-files --others --exclude-standard)' command substitution, and displays the indicator when there is no output. Avoid this command substitution by additionally passing '--error-unmatch *', and checking the command's return value. Signed-off-by: SZEDER Gábor --- This seems to do the right thing, but I'm not quite sure, so I would appreciate a pair of expert eyeballs on it. contrib/completion/git-completion.bash | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index c4feab68..5ea19018 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -348,9 +348,8 @@ __git_ps1 () fi if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then - if [ -n "$(git ls-files --others --exclude-standard)" ]; then - u="%" - fi + git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null && + u="%" fi fi fi -- 1.7.10.1.541.gb1be298