git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Anton Mitterer <calestyo@scientia.net>
To: Git Mailing List <git@vger.kernel.org>
Subject: Re: git-sh-prompt: bash: GIT_PS1_COMPRESSSPARSESTATE: unbound variable
Date: Wed, 19 May 2021 19:56:53 +0200	[thread overview]
Message-ID: <681aefe15af98f6758f28544b96bc2eca90642f3.camel@scientia.net> (raw)
In-Reply-To: <xmqqv97nb51b.fsf@gitster.g>

Hey there.

I think I found another case of an unbound variable:

Completing e.g.:
git commit --[press TAB]

gives:
$ git commit  --bash: GIT_COMPLETION_SHOW_ALL: unbound variable


with some debugging:
$ set -xv
$ git commit --+ __git_func_wrap __git_main
+ local cur words cword prev
+ _get_comp_words_by_ref -n =: cur words cword prev
+ local exclude flag i OPTIND=1
+ words=()
+ local cur cword words
+ upargs=()
+ upvars=()
+ local upargs upvars vcur vcword vprev vwords
+ getopts c:i:n:p:w: flag -n =: cur words cword prev
+ case $flag in
+ exclude==:
+ getopts c:i:n:p:w: flag -n =: cur words cword prev
+ [[ 6 -ge 3 ]]
+ case ${!OPTIND} in
+ vcur=cur
+ (( OPTIND += 1 ))
+ [[ 6 -ge 4 ]]
+ case ${!OPTIND} in
+ vwords=words
+ (( OPTIND += 1 ))
+ [[ 6 -ge 5 ]]
+ case ${!OPTIND} in
+ vcword=cword
+ (( OPTIND += 1 ))
+ [[ 6 -ge 6 ]]
+ case ${!OPTIND} in
+ vprev=prev
+ (( OPTIND += 1 ))
+ [[ 6 -ge 7 ]]
+ __get_cword_at_cursor_by_ref =: words cword cur
+ words=()
+ local cword words
+ __reassemble_comp_words_by_ref =: words cword
+ local exclude i j line ref
+ [[ -n =: ]]
+ exclude='[=:]'
+ printf -v cword %s 2
+ [[ -v exclude ]]
+ line='git commit --'
+ (( i = 0, j = 0 ))
+ (( i < 3 ))
+ [[ 0 -gt 0 ]]
+ ref='words[0]'
+ printf -v 'words[0]' %s git
+ line=' commit --'
+ (( i == COMP_CWORD ))
+ (( i++, j++ ))
+ (( i < 3 ))
+ [[ 1 -gt 0 ]]
+ [[ commit == +([=:]) ]]
+ ref='words[1]'
+ printf -v 'words[1]' %s commit
+ line=' --'
+ (( i == COMP_CWORD ))
+ (( i++, j++ ))
+ (( i < 3 ))
+ [[ 2 -gt 0 ]]
+ [[ -- == +([=:]) ]]
+ ref='words[2]'
+ printf -v 'words[2]' %s --
+ line=
+ (( i == COMP_CWORD ))
+ printf -v cword %s 2
+ (( i++, j++ ))
+ (( i < 3 ))
+ (( i == COMP_CWORD ))
+ local i cur= index=13 'lead=git commit --'
+ [[ 13 -gt 0 ]]
+ [[ -n git commit -- ]]
+ [[ -n gitcommit-- ]]
+ cur='git commit --'
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 13 -ge 3 ]]
+ [[ git != \g\i\t ]]
+ (( i < cword ))
+ local old_size=13
+ cur=' commit --'
+ local new_size=10
+ (( index -= old_size - new_size ))
+ (( ++i ))
+ (( i <= cword ))
+ [[ 10 -ge 6 ]]
+ [[  commi != \c\o\m\m\i\t ]]
+ cur='commit --'
+ (( index > 0 ))
+ (( index-- ))
+ [[ 9 -ge 6 ]]
+ [[ commit != \c\o\m\m\i\t ]]
+ (( i < cword ))
+ local old_size=9
+ cur=' --'
+ local new_size=3
+ (( index -= old_size - new_size ))
+ (( ++i ))
+ (( i <= cword ))
+ [[ 3 -ge 2 ]]
+ [[  - != \-\- ]]
+ cur=--
+ (( index > 0 ))
+ (( index-- ))
+ [[ 2 -ge 2 ]]
+ [[ -- != \-\- ]]
+ (( i < cword ))
+ (( ++i ))
+ (( i <= cword ))
+ [[ -n -- ]]
+ [[ ! -n -- ]]
+ (( index < 0 ))
+ local words cword cur
+ _upvars -a3 words git commit -- -v cword 2 -v cur --
+ (( 11 ))
+ (( 11 ))
+ case $1 in
+ [[ -n 3 ]]
+ printf %d 3
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:3}")'
words=("${@:3:3}")
++ words=("${@:3:3}")
+ shift 5
+ (( 6 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
cword="$3"
++ cword=2
+ shift 3
+ (( 3 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
cur="$3"
++ cur=--
+ shift 3
+ (( 0 ))
+ [[ -v vcur ]]
+ upvars+=("$vcur")
+ upargs+=(-v $vcur "$cur")
+ [[ -v vcword ]]
+ upvars+=("$vcword")
+ upargs+=(-v $vcword "$cword")
+ [[ -v vprev ]]
+ [[ 2 -ge 1 ]]
+ upvars+=("$vprev")
+ upargs+=(-v $vprev "${words[cword - 1]}")
+ [[ -v vwords ]]
+ upvars+=("$vwords")
+ upargs+=(-a${#words[@]} $vwords ${words+"${words[@]}"})
+ (( 4 ))
+ local cur cword prev words
+ _upvars -v cur -- -v cword 2 -v prev commit -a3 words git commit --
+ (( 14 ))
+ (( 14 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
cur="$3"
++ cur=--
+ shift 3
+ (( 11 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
cword="$3"
++ cword=2
+ shift 3
+ (( 8 ))
+ case $1 in
+ [[ -n prev ]]
+ unset -v prev
+ eval 'prev="$3"'
prev="$3"
++ prev=commit
+ shift 3
+ (( 5 ))
+ case $1 in
+ [[ -n 3 ]]
+ printf %d 3
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:3}")'
words=("${@:3:3}")
++ words=("${@:3:3}")
+ shift 5
+ (( 0 ))
+ __git_main
+ local i c=1 command __git_dir __git_repo_path
+ local __git_C_args C_args_count=0
+ '[' 1 -lt 2 ']'
+ i=commit
+ case "$i" in
+ command=commit
+ break
+ '[' -z commit ']'
+ __git_complete_command commit
+ local command=commit
+ local completion_func=_git_commit
+ __git_have_func _git_commit
+ declare -f -- _git_commit
+ __git_have_func _git_commit
+ declare -f -- _git_commit
+ _git_commit
+ case "$prev" in
+ case "$cur" in
+ __gitcomp_builtin commit
+ local cmd=commit
+ local incl=
+ local excl=
+ local var=__gitcomp_builtin_commit
+ local options
+ eval 'options=${__gitcomp_builtin_commit-}'
options=${__gitcomp_builtin_commit-}
++ options=
+ '[' -z '' ']'
+ local completion_helper
bash: GIT_COMPLETION_SHOW_ALL: unbound variable

These seem to be in: 
/usr/share/bash-completion/completions/git
and possibly also:
/usr/share/bash-completion/completions/gitk


Cheers,
Chris.


  reply	other threads:[~2021-05-19 17:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13  3:38 git-sh-prompt: bash: GIT_PS1_COMPRESSSPARSESTATE: unbound variable Christoph Anton Mitterer
2021-05-13  4:03 ` Junio C Hamano
2021-05-13  4:13   ` Junio C Hamano
2021-05-13  4:53     ` Elijah Newren
2021-05-13  5:01       ` Junio C Hamano
2021-05-19 17:56         ` Christoph Anton Mitterer [this message]
2021-05-19 23:29           ` Junio C Hamano
2021-05-20  0:09             ` Elijah Newren
2021-05-13 13:08   ` Christoph Anton Mitterer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=681aefe15af98f6758f28544b96bc2eca90642f3.camel@scientia.net \
    --to=calestyo@scientia.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).