mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-16 19:00:07 +00:00
gitfast: fix error in git-prompt.sh (#8132)
An error was thrown (`bash: [: =: unary operator expected`) when using the __git_ps1_colorize_gitstring function outside of the one place it's called (line 512), because the "detached" variable was not quoted, and was unset.
This commit is contained in:
commit
f9e133b88a
1 changed files with 6 additions and 6 deletions
|
@ -219,7 +219,7 @@ __git_ps1_show_upstream ()
|
||||||
if [[ -n "$count" && -n "$name" ]]; then
|
if [[ -n "$count" && -n "$name" ]]; then
|
||||||
__git_ps1_upstream_name=$(git rev-parse \
|
__git_ps1_upstream_name=$(git rev-parse \
|
||||||
--abbrev-ref "$upstream" 2>/dev/null)
|
--abbrev-ref "$upstream" 2>/dev/null)
|
||||||
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
|
if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then
|
||||||
p="$p \${__git_ps1_upstream_name}"
|
p="$p \${__git_ps1_upstream_name}"
|
||||||
else
|
else
|
||||||
p="$p ${__git_ps1_upstream_name}"
|
p="$p ${__git_ps1_upstream_name}"
|
||||||
|
@ -237,7 +237,7 @@ __git_ps1_show_upstream ()
|
||||||
# to build a gitstring.
|
# to build a gitstring.
|
||||||
__git_ps1_colorize_gitstring ()
|
__git_ps1_colorize_gitstring ()
|
||||||
{
|
{
|
||||||
if [[ -n ${ZSH_VERSION-} ]]; then
|
if [[ -n "${ZSH_VERSION-}" ]]; then
|
||||||
local c_red='%F{red}'
|
local c_red='%F{red}'
|
||||||
local c_green='%F{green}'
|
local c_green='%F{green}'
|
||||||
local c_lblue='%F{blue}'
|
local c_lblue='%F{blue}'
|
||||||
|
@ -255,7 +255,7 @@ __git_ps1_colorize_gitstring ()
|
||||||
local flags_color="$c_lblue"
|
local flags_color="$c_lblue"
|
||||||
|
|
||||||
local branch_color=""
|
local branch_color=""
|
||||||
if [ $detached = no ]; then
|
if [ "$detached" = no ]; then
|
||||||
branch_color="$ok_color"
|
branch_color="$ok_color"
|
||||||
else
|
else
|
||||||
branch_color="$bad_color"
|
branch_color="$bad_color"
|
||||||
|
@ -508,13 +508,13 @@ __git_ps1 ()
|
||||||
|
|
||||||
# NO color option unless in PROMPT_COMMAND mode or it's Zsh
|
# NO color option unless in PROMPT_COMMAND mode or it's Zsh
|
||||||
if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
|
if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
|
||||||
if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
|
if [ "$pcmode" = yes ] || [ -n "${ZSH_VERSION-}" ]; then
|
||||||
__git_ps1_colorize_gitstring
|
__git_ps1_colorize_gitstring
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
b=${b##refs/heads/}
|
b=${b##refs/heads/}
|
||||||
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
|
if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then
|
||||||
__git_ps1_branch_name=$b
|
__git_ps1_branch_name=$b
|
||||||
b="\${__git_ps1_branch_name}"
|
b="\${__git_ps1_branch_name}"
|
||||||
fi
|
fi
|
||||||
|
@ -522,7 +522,7 @@ __git_ps1 ()
|
||||||
local f="$w$i$s$u"
|
local f="$w$i$s$u"
|
||||||
local gitstring="$c$b${f:+$z$f}$r$p"
|
local gitstring="$c$b${f:+$z$f}$r$p"
|
||||||
|
|
||||||
if [ $pcmode = yes ]; then
|
if [ "$pcmode" = yes ]; then
|
||||||
if [ "${__git_printf_supports_v-}" != yes ]; then
|
if [ "${__git_printf_supports_v-}" != yes ]; then
|
||||||
gitstring=$(printf -- "$printf_format" "$gitstring")
|
gitstring=$(printf -- "$printf_format" "$gitstring")
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue