Skip to content

Commit

Permalink
completion: Fix zsh parsing $GIT_PS1_SHOWUPSTREAM
Browse files Browse the repository at this point in the history
Since GIT_PS1_SHOWUPSTREAM is a variable with space separated values and
zsh for loops do no split by space by default. The `-d' '` is a hacky
solution that works in both bash and zsh. The correct way to do that in
zsh would be do use read -rA and loop over the resulting array but -A is
not defined in bash.

Signed-off-by: Thomas Queiroz <thomasqueirozb@gmail.com>
  • Loading branch information
thomasqueirozb committed Apr 19, 2024
1 parent 21306a0 commit d5c7ca9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contrib/completion/git-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ __git_ps1_show_upstream ()

# parse configuration values
local option
for option in ${GIT_PS1_SHOWUPSTREAM-}; do
while read -r -d' ' option; do
case "$option" in
git|svn) upstream_type="$option" ;;
verbose) verbose=1 ;;
legacy) legacy=1 ;;
name) name=1 ;;
esac
done
done <<< "${GIT_PS1_SHOWUPSTREAM-} "

# Find our upstream type
case "$upstream_type" in
Expand Down

0 comments on commit d5c7ca9

Please sign in to comment.