threads / discuss / 25930

Re: bash 4.0 breaks some completion scripts

Subject: Re: bash 4.0 breaks some completion scripts

## tl;dr

2 messages between Dec 2, 2010 and Dec 3, 2010.

replies: 1people: 2as markdown or json

Jonathan Nieder· Dec 2, 2010, 23:38 UTC · lore
Jonathan Nieder wrote:
> Bash 4.0 changed the rules for completion word splitting so that
> they are incompatible with 3.x.  I think some Breaks: will be needed
> to ensure smooth upgrades.
Just FYI: Ah, at last some clarity!
>From the bash 3 manual:
 COMP_WORDS
	An array variable (see Arrays below) consisting of the
	individual words in the current command line.  The
	words are split on shell metacharacters as the shell
	parser would separate them.  This variable is
	available only in shell functions invoked by the
	programmable completion facilities (see Programmable
	Completion below).
>From the bash 4 manual:
 COMP_WORDS
	An array variable (see Arrays below) consisting of the
	individual words in the current command line.  The
	line is split into words as readline would split it,
	using COMP_WORDBREAKS as described above.  This
	variable is available only in shell functions invoked
	by the programmable completion facilities (see
	Programmable Completion below).

The workaround used by the bash-completion scripts is to paste words from COMP_WORDS together (in _get_comp_words_by_ref).

If only the NEWS file had mentioned it. :)  
SZEDER Gábor· Dec 3, 2010, 00:11 UTC · re: Jonathan Nieder · lore
Hi,
On Thu, Dec 02, 2010 at 05:38:48PM -0600, Jonathan Nieder wrote:
Show 29 quoted lines
> Jonathan Nieder wrote:
> 
> > Bash 4.0 changed the rules for completion word splitting so that
> > they are incompatible with 3.x.  I think some Breaks: will be needed
> > to ensure smooth upgrades.
> 
> Just FYI: Ah, at last some clarity!
> 
> From the bash 3 manual:
> 
>  COMP_WORDS
> 	An array variable (see Arrays below) consisting of the
> 	individual words in the current command line.  The
> 	words are split on shell metacharacters as the shell
> 	parser would separate them.  This variable is
> 	available only in shell functions invoked by the
> 	programmable completion facilities (see Programmable
> 	Completion below).
> 
> From the bash 4 manual:
> 
>  COMP_WORDS
> 	An array variable (see Arrays below) consisting of the
> 	individual words in the current command line.  The
> 	line is split into words as readline would split it,
> 	using COMP_WORDBREAKS as described above.  This
> 	variable is available only in shell functions invoked
> 	by the programmable completion facilities (see
> 	Programmable Completion below).

Oh dear, oh dear. I've just sent a reply to your message on the git list with basically the same findigs. [1]

> The workaround used by the bash-completion scripts is to paste words
> from COMP_WORDS together (in _get_comp_words_by_ref).
> 
> If only the NEWS file had mentioned it. :)  

Actually, the NEWS file does mention it (and Peter noted it right at the start! [2]):

i.  The programmable completion code now uses the same set of characters as
    readline when breaking the command line into a list of words.

But it's really easy to misinterpret this statement, because there is and there was a $COMP_WORDBREAKS, so the first thing that comes to mind is that the set of characters in $COMP_WORDBREAKS is changed, leaving you puzzled for weeks when you discover that the set of characters is still the same.

Best, Gábor

[1] http://marc.info/?l=git&m=129133327312420&w=2 [2] http://thread.gmane.org/gmane.comp.version-control.git/159516/focus=159628

← back to recent threads