git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: SZEDER GáborNext: Stephen Boyd
Message 12 of 22 in “*** SUBJECT HERE ***”
  1. 0/2 *** SUBJECT HERE ***Peter van der Does, Dec 1, 2010
  2. 1/2 Introduce functions from bash-completion project.Peter van der Does, Dec 1, 2010
  3. 2/2 Use the new functions to get the current cword.Peter van der Does, Dec 1, 2010
  4. Jonathan NiederDec 2, 2010
  5. SZEDER GáborDec 2, 2010
  6. Jonathan NiederDec 1, 2010
  7. SZEDER GáborDec 2, 2010
  8. Jonathan NiederDec 2, 2010
  9. Peter van der DoesDec 2, 2010
  10. 2/1 bash: eliminate dependency on bash_completion libJonathan Nieder, Dec 2, 2010
  11. SZEDER GáborDec 2, 2010
  12. Jonathan NiederDec 3, 2010
  13. Stephen BoydDec 3, 2010
  14. SZEDER GáborDec 7, 2010
  15. Jonathan NiederDec 7, 2010
  16. SZEDER GáborDec 7, 2010
  17. Jonathan NiederDec 7, 2010
  18. Junio C HamanoDec 7, 2010
  19. 0/3 Make git-completion Bash 4 compatibleJonathan Nieder, Dec 15, 2010
  20. 1/3 bash: get --pretty=m<tab> completion to work with bash v4Jonathan Nieder, Dec 15, 2010
  21. 2/3 bash: simple reimplementation of _get_comp_words_by_refJonathan Nieder, Dec 15, 2010
  22. 3/3 Merge branch 'master' (early part) into pd/bash-4-completionJonathan Nieder, Dec 15, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.