Bug#601632: bash 4.0 breaks some completion scripts

2010-12-02 Thread Jonathan Nieder
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. :)  



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#601632: bash 4.0 breaks some completion scripts

2010-12-02 Thread SZEDER Gábor
Hi,


On Thu, Dec 02, 2010 at 05:38:48PM -0600, Jonathan Nieder wrote:
 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=gitm=129133327312420w=2
[2] http://thread.gmane.org/gmane.comp.version-control.git/159516/focus=159628




-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#601632: bash 4.0 breaks some completion scripts

2010-10-27 Thread Jonathan Nieder
Package: bash
Version: 4.1-3
Severity: important

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.

The closest to a hint NEWS provides is:

 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 the problem is something else --- with exactly the same
COMP_WORDBREAKS, earlier and later versions show different behavior.

Example:

 . /etc/bash_completion.d/git
 git log --pretty=tabtab

lists medium, full, etc with bash 3.0 but falls back to completing on
files in the cwd in bash 4.0.

The bash_completion project works around this by introducing a
_get_cword function abstracting the differences away:

| commit f733e71e1f8d63c072a402346d8162f9c6b63ae2
| Date:   Sun Sep 20 14:11:26 2009 +0200
| 
| Split _get_cword into bash-3/4 versions
[...]
| Bash-4 splits COMP_WORDS using characters from COMP_WORDBREAKS, but has
| a bug where quoted words are also splitted, see:
| http://www.mail-archive.com/bug-b...@gnu.org/msg06095.html
|
| __get_cword3 is used for bash-2/3 and __get_cword4 is used for bash-4.

and has refined this over time to a _get_comp_words_by_ref function
using only functionality that works correctly with both bash versions.

The upshot:

 1. bash-completion versions before 1.1 are broken by bash 4.

 2. All known versions of git's completion script are broken by bash 4.
There is a patch cooking on the git mailing list to get it working
again.

 3. Other completion scripts might need changes, too.  There are about
74 packages to check :(, based on

zgrep bash_completion.d Contents-i386.gz |
sed -e 's/.*  *//' |
cut -d'/' -f2 |
uniq |
wc -l

Any ideas for reducing the work of finding versions to Breaks:?



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#601632: bash 4.0 breaks some completion scripts

2010-10-27 Thread Jonathan Nieder
Jonathan Nieder wrote:

  1. bash-completion versions before 1.1 are broken by bash 4.
 
  2. All known versions of git's completion script are broken by bash 4.
 There is a patch cooking on the git mailing list to get it working
 again.
 
  3. Other completion scripts might need changes, too.  There are about
 74 packages to check :(

Oops, forgot to include references.

bash list
-
* Some quoting issue led to the splitting of _get_cword:
  http://thread.gmane.org/gmane.comp.shells.bash.bugs/13440
* The advertised behavior change (a new default for COMP_WORDBREAKS
  includes '='):
  http://thread.gmane.org/gmane.comp.shells.bash.bugs/15035
* The git log --pretty=tabtab bug:
  http://thread.gmane.org/gmane.comp.shells.bash.bugs/14046

git list

* report that completion broke.  COMP_WORKBREAKS already included '='...
  http://thread.gmane.org/gmane.comp.version-control.git/159448/focus=159481
* triage.
  http://thread.gmane.org/gmane.comp.version-control.git/159516/focus=159628
* first revision of patch.
  http://thread.gmane.org/gmane.comp.version-control.git/159991
* second revision of patch.
  http://thread.gmane.org/gmane.comp.version-control.git/160103

Upshot of the git discussion:

| This ${COMP_WORDS[COMP_CWORD]}
| construct apparently is not the right way to find the word to complete
| anymore, assuming you want your completion script to work with bash 4
| and 3 as well.  Unfortunately, we use this construct all over the
| place.



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org