bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Resolving quoted COMP_CWORD on bash-4


From: Freddy Vulto
Subject: Resolving quoted COMP_CWORD on bash-4
Date: Thu, 17 Sep 2009 22:41:57 +0200

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include
-I./lib   -g -O2
uname output: Linux myhost 2.6.28-15-generic #49-Ubuntu SMP Tue Aug 18
18:40:08 UTC 2009 i686 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 4.0
Patch Level: 28
Release Status: release

On bash-4, when completing:

    $ a 'b c

The COMP_CWORD variables contain:

    COMP_CWORD: 3
    COMP_CWORDS:
    0: a
    1: '
    2: b
    3: c

Whereas on bash-3 they contained:

    COMP_CWORD: 1
    COMP_CWORDS:
    0: a
    1: 'b c

I know that bash-4 has changed:

    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 how is one to determine that the current word being completed is
"b c" and not "c"?  Shouldn't the programmable completion code *not*
break the current word if it's quoted?

Steps to reproduce:

1.  Create function `_cword' and let it complete `a':

    _cword() {
       echo
       echo COMP_CWORD: $COMP_CWORD
       echo COMP_CWORDS:
       for ((i=0; i < address@hidden; i++)); do
           echo $i: "${COMP_WORDS[$i]}"
       done
    }
    complete -F _cword a

2.  Complete `a':

    $ a 'b c<TAB>


Regards,

Freddy Vulto
http://fvue.nl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]