Re: [RFC/PATCH 2/1] bash: eliminate dependency on bash_completion lib
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Dec 3, 2010, 00:07 UTC
- Message-ID
- <20101203000723.GB8438@burratino>
- In-Reply-To
- <20101202234053.GB3577@neumann>
SZEDER Gábor wrote:
Show 20 quoted lines
> Bash's programmable completion provides the COMP_WORDS array variable, > which holds the individual words in the current command line. In Bash > versions prior to v4 "words are split on shell metacharacters as the > shell parser would separate them" (quote from bash v3.2.48's man > page). This behavior has changed with Bash v4, and the command line > "is split into words as readline would split it, using COMP_WORDBREAKS > as" "the set of characters that the readline library treats as word > separators" (quote from bash v4's man page). > > Since COMP_WORDBREAKS contains the characters : and = by default, this > behavior change in Bash also affects git's completion script. For > example, when using Bash v4 the completion script can't provide > possible options for a command line argument (e.g. git log > --pretty=<TAB><TAB> lists files, but it should list possible log > formats). > > > I would really, _really_ like to have the above text in the commit > message (either in yours or in Peter's), because it took me weeks to > figure this out ;)
Sounds good.
> (I'm still wondering what Bash v3.x was doing with COMP_WORDBREAKS, > though...)
Based on v1.5.6.4~9^2 (bash completion: Resolve git show ref:path<tab> losing ref: portion, 2008-07-15) it seems COMP_WORDBREAKS determined the interpretation of COMPREPLY (result of completion). Of course it also governed standard filename completion.
> On Thu, Dec 02, 2010 at 03:02:07PM -0600, Jonathan Nieder wrote:
>> +++ b/contrib/completion/git-completion.bash >> @@ -327,7 +327,102 @@ __gitcomp_1 ()
[...]
Show 6 quoted lines
>> +# This function can be used to access a tokenized list of words >> +# on the command line: >> +# >> +# __reassemble_comp_words_by_ref '=:' > > __git_reassemble_comp_words_by_ref?
[...]
>> if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
>> +if [[ -n $ZSH_VERSION ]]; then
>
> This should be ${ZSH_VERSION-} to keep 'set -u' environments happy.Nice catches; thanks.