diff options
author | Addison G <AddisonG@users.noreply.github.com> | 2019-09-06 14:12:56 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-06 14:12:56 +1000 |
commit | 1f58cd92ddb94fb75e4fb45f231eebfd55aa19dd (patch) | |
tree | 0e5b38430e3d29d267f723ca96759a401b948dab /plugins/gitfast/git-prompt.sh | |
parent | a4f6a9964ceec3d222a8caa8eb3e5cf6027cfbab (diff) | |
download | zsh-1f58cd92ddb94fb75e4fb45f231eebfd55aa19dd.tar.gz zsh-1f58cd92ddb94fb75e4fb45f231eebfd55aa19dd.tar.bz2 zsh-1f58cd92ddb94fb75e4fb45f231eebfd55aa19dd.zip |
Updated git-prompt.sh to quote variables
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.
Diffstat (limited to 'plugins/gitfast/git-prompt.sh')
-rw-r--r-- | plugins/gitfast/git-prompt.sh | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh index fd2b049db..3e86e9cca 100644 --- a/plugins/gitfast/git-prompt.sh +++ b/plugins/gitfast/git-prompt.sh @@ -219,7 +219,7 @@ __git_ps1_show_upstream () if [[ -n "$count" && -n "$name" ]]; then __git_ps1_upstream_name=$(git rev-parse \ --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}" else p="$p ${__git_ps1_upstream_name}" @@ -237,7 +237,7 @@ __git_ps1_show_upstream () # to build a gitstring. __git_ps1_colorize_gitstring () { - if [[ -n ${ZSH_VERSION-} ]]; then + if [[ -n "${ZSH_VERSION-}" ]]; then local c_red='%F{red}' local c_green='%F{green}' local c_lblue='%F{blue}' @@ -255,7 +255,7 @@ __git_ps1_colorize_gitstring () local flags_color="$c_lblue" local branch_color="" - if [ $detached = no ]; then + if [ "$detached" = no ]; then branch_color="$ok_color" else branch_color="$bad_color" @@ -508,13 +508,13 @@ __git_ps1 () # NO color option unless in PROMPT_COMMAND mode or it's Zsh if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then - if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then + if [ "$pcmode" = "yes" ] || [ -n "${ZSH_VERSION-}" ]; then __git_ps1_colorize_gitstring fi fi b=${b##refs/heads/} - if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then + if [ "$pcmode" = "yes" ] && [ "$ps1_expanded" = "yes" ]; then __git_ps1_branch_name=$b b="\${__git_ps1_branch_name}" fi @@ -522,8 +522,8 @@ __git_ps1 () local f="$w$i$s$u" local gitstring="$c$b${f:+$z$f}$r$p" - if [ $pcmode = yes ]; then - if [ "${__git_printf_supports_v-}" != yes ]; then + if [ "$pcmode" = "yes" ]; then + if [ "${__git_printf_supports_v-}" != "yes" ]; then gitstring=$(printf -- "$printf_format" "$gitstring") else printf -v gitstring -- "$printf_format" "$gitstring" |