Package: bash
Version: 3.1dfsg-8
Severity: minor
Tags: patch

For completions using the _command function, any attempt to complete
either - or -- results in an error message.  For example

time -<Tab>

would print "bash: COMP_WORDS: bad array subscript" and would then print
possible file completions (not limited to files starting with -).  I
have attached a patch that I believe fixes the issue (by preventing
indexing past COMP_CWORD and providing a check to stop looping).

Cheers,
Kevin


-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.18.20070225a
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages bash depends on:
ii  base-files                  4            Debian base system miscellaneous f
ii  debianutils                 2.17         Miscellaneous utilities specific t
ii  libc6                       2.3.6.ds1-13 GNU C Library: Shared libraries
ii  libncurses5                 5.5-5        Shared libraries for terminal hand

bash recommends no packages.

-- no debconf information
--- bash_completion     2007-03-17 14:44:47.000000000 -0400
+++ bash_completion     2007-03-17 14:45:26.000000000 -0400
@@ -3099,9 +3099,9 @@
        # switches, get rid of them. Most definitely not foolproof.
        done=
        while [ -z $done ] ; do
-       cmd=${COMP_WORDS[1]}
-           if [[ "$cmd" == -* ]] ; then
-               for (( i=1 ; i<=COMP_CWORD ; i++)) ; do
+           cmd=${COMP_WORDS[1]}
+           if [[ "$cmd" == -* ]] && [ $COMP_CWORD -gt 1 ]; then
+               for (( i=1 ; i<COMP_CWORD ; i++)) ; do
                    COMP_WORDS[i]=${COMP_WORDS[i+1]}
                done
                COMP_CWORD=$(($COMP_CWORD-1))

Reply via email to