bash prompt: avoid command substitution when checking for untracked files

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 <szeder@ira.uka.de>

SZEDER Gábor committed Aug 12, 2011 at 14:17 UTC 14d7649748265fe9fe991439ca6ae0c9db7a27ab
1 file changed +1 -1
contrib/completion/git-prompt.sh
+1 -1
@@ -442,7 +442,7 @@ __git_ps1 ()
442
443 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
444 [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
445 - [ -n "$(git ls-files --others --exclude-standard)" ]
445 + git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
446 then
447 u="%${ZSH_VERSION+%}"
448 fi