Merge branch 'bc/completion-for-bash-3.0' into maint
Some people still use rather old versions of bash, which cannot grok some constructs like 'printf -v varname' the prompt and completion code started to use recently. * bc/completion-for-bash-3.0: contrib/git-prompt.sh: handle missing 'printf -v' more gracefully t9902-completion.sh: old Bash still does not support array+=('') notation git-completion.bash: use correct Bash/Zsh array length syntax
This commit is contained in:
commit
ebb9d1968a
@ -2580,7 +2580,7 @@ if [[ -n ${ZSH_VERSION-} ]]; then
|
|||||||
--*=*|*.) ;;
|
--*=*|*.) ;;
|
||||||
*) c="$c " ;;
|
*) c="$c " ;;
|
||||||
esac
|
esac
|
||||||
array[$#array+1]="$c"
|
array[${#array[@]}+1]="$c"
|
||||||
done
|
done
|
||||||
compset -P '*[=:]'
|
compset -P '*[=:]'
|
||||||
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
|
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
|
||||||
|
@ -84,6 +84,10 @@
|
|||||||
# the colored output of "git status -sb" and are available only when
|
# the colored output of "git status -sb" and are available only when
|
||||||
# using __git_ps1 for PROMPT_COMMAND or precmd.
|
# using __git_ps1 for PROMPT_COMMAND or precmd.
|
||||||
|
|
||||||
|
# check whether printf supports -v
|
||||||
|
__git_printf_supports_v=
|
||||||
|
printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
|
||||||
|
|
||||||
# stores the divergence from upstream in $p
|
# stores the divergence from upstream in $p
|
||||||
# used by GIT_PS1_SHOWUPSTREAM
|
# used by GIT_PS1_SHOWUPSTREAM
|
||||||
__git_ps1_show_upstream ()
|
__git_ps1_show_upstream ()
|
||||||
@ -433,7 +437,7 @@ __git_ps1 ()
|
|||||||
local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
|
local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
|
||||||
|
|
||||||
if [ $pcmode = yes ]; then
|
if [ $pcmode = yes ]; then
|
||||||
if [[ -n ${ZSH_VERSION-} ]]; then
|
if [ "${__git_printf_supports_v-}" != yes ]; then
|
||||||
gitstring=$(printf -- "$printf_format" "$gitstring")
|
gitstring=$(printf -- "$printf_format" "$gitstring")
|
||||||
else
|
else
|
||||||
printf -v gitstring -- "$printf_format" "$gitstring"
|
printf -v gitstring -- "$printf_format" "$gitstring"
|
||||||
|
@ -69,7 +69,7 @@ run_completion ()
|
|||||||
local -a COMPREPLY _words
|
local -a COMPREPLY _words
|
||||||
local _cword
|
local _cword
|
||||||
_words=( $1 )
|
_words=( $1 )
|
||||||
test "${1: -1}" = ' ' && _words+=('')
|
test "${1: -1}" = ' ' && _words[${#_words[@]}+1]=''
|
||||||
(( _cword = ${#_words[@]} - 1 ))
|
(( _cword = ${#_words[@]} - 1 ))
|
||||||
__git_wrap__git_main && print_comp
|
__git_wrap__git_main && print_comp
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user