On Sun, 08 Jan 2012 16:38:02 +0200, Ville Skyttä wrote:

> On 2012-01-08 14:43, David Paleino wrote:
> > Hello people,
> > please consider the following snippet:
> > 
> > --->8---
> > _foo() {
> >     local cur prev words cword
> >     _init_completion -n = || return
> >     
> >     case $cur in
> >         bar=*)
> >             cur=${cur#*=}
> >             _filedir
> >             return 0
> >             ;;
> >     esac
> > 
> >     _expand || return 0
> > 
> >     COMPREPLY=( $(compgen -W 'bar' -S'=' -- "$cur") )
> >     return 0
> > }
> > complete -F _foo -o nospace foo
> > ---8<---
> > 
> > What I get is:
> > 
> > $ foo bar=<TAB>
> > abc
> > bla
> > foo
> > $ foo bar=b<TAB>
> > $ foo bla
> 
> What I get is (assuming there are abc, bla, and foo files in $PWD):
> 
> $ foo bar=<TAB>
> abc  bla  foo
> $ foo bar=b<TAB>
> $ foo bar=bla
> 
> ...so I suppose it's working as expected for me.  This is on Fedora 16,
> bash-completion current git master, bash 4.2.20(1)-release.

Same bashcomp and bash version here. But on Debian :o)

I'm attaching the "set -x" output when I do foo bar=b<TAB> (truly speaking,
it's bar=ac<TAB>, trying to complete some aclocal.m4 I have in the current
directory).

Would you mind comparing it to yours?

Thanks,
David

-- 
 . ''`.   Debian developer | http://wiki.debian.org/DavidPaleino
 : :'  : Linuxer #334216 --|-- http://www.hanskalabs.net/
 `. `'`  GPG: 1392B174 ----|---- http://deb.li/dapal
   `-   2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174
$ foo bar=ac+ local compdir=./completions
+ [[ /deb/git/upstream/bash-completion/bash_completion == */* ]]
+ compdir=/deb/git/upstream/bash-completion/completions
+ . /deb/git/upstream/bash-completion/completions/foo
+ return 124
+ local cur prev words cword
+ _init_completion -n =
+ local exclude= flag outx errx inx OPTIND=1
+ getopts n:e:o:i:s flag -n =
+ case $flag in
+ exclude+==
+ getopts n:e:o:i:s flag -n =
+ COMPREPLY=()
+ local 'redir=@(?([0-9])<|?([0-9&])>?(>)|>&)'
+ _get_comp_words_by_ref -n '=<>&' cur prev words cword
+ local exclude flag i OPTIND=1
+ words=()
+ local cur cword words
+ upargs=()
+ upvars=()
+ local upargs upvars vcur vcword vprev vwords
+ getopts c:i:n:p:w: flag -n '=<>&' cur prev words cword
+ case $flag in
+ exclude='=<>&'
+ getopts c:i:n:p:w: flag -n '=<>&' cur prev words cword
+ [[ 6 -ge 3 ]]
+ case ${!OPTIND} in
+ vcur=cur
+ let 'OPTIND += 1'
+ [[ 6 -ge 4 ]]
+ case ${!OPTIND} in
+ vprev=prev
+ let 'OPTIND += 1'
+ [[ 6 -ge 5 ]]
+ case ${!OPTIND} in
+ vwords=words
+ let 'OPTIND += 1'
+ [[ 6 -ge 6 ]]
+ case ${!OPTIND} in
+ vcword=cword
+ let 'OPTIND += 1'
+ [[ 6 -ge 7 ]]
+ __get_cword_at_cursor_by_ref '=<>&' words cword cur
+ words=()
+ local cword words
+ __reassemble_comp_words_by_ref '=<>&' words cword
+ local exclude i j line ref
+ [[ -n =<>& ]]
+ exclude='<>&'
+ eval cword=1
++ cword=1
+ [[ -n <>& ]]
+ line='foo bar=ac'
+ (( i=0, j=0 ))
+ (( i < 2 ))
+ [[ 0 -gt 0 ]]
+ ref='words[0]'
+ eval 'words[0]=${!ref}${COMP_WORDS[i]}'
++ words[0]=foo
+ line=' bar=ac'
+ [[ 0 == 1 ]]
+ (( i++, j++ ))
+ (( i < 2 ))
+ [[ 1 -gt 0 ]]
+ [[ bar=ac == +([<>&]) ]]
+ ref='words[1]'
+ eval 'words[1]=${!ref}${COMP_WORDS[i]}'
++ words[1]=bar=ac
+ line=
+ [[ 1 == 1 ]]
+ eval cword=1
++ cword=1
+ (( i++, j++ ))
+ (( i < 2 ))
+ local i cur index=10 'lead=foo bar=ac'
+ [[ 10 -gt 0 ]]
+ [[ -n foo bar=ac ]]
+ [[ -n foobar=ac ]]
+ cur='foo bar=ac'
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 10 -ge 3 ]]
+ [[ foo != \f\o\o ]]
+ [[ 0 -lt 1 ]]
+ local old_size=10
+ cur=' bar=ac'
+ local new_size=7
+ index=7
+ (( ++i  ))
+ (( i <= cword ))
+ [[ 7 -ge 6 ]]
+ [[  bar=a != \b\a\r\=\a\c ]]
+ cur=bar=ac
+ (( index-- ))
+ [[ 6 -ge 6 ]]
+ [[ bar=ac != \b\a\r\=\a\c ]]
+ [[ 1 -lt 1 ]]
+ (( ++i  ))
+ (( i <= cword ))
+ [[ -n bar=ac ]]
+ [[ ! -n bar=ac ]]
+ [[ 6 -lt 0 ]]
+ local words cword cur
+ _upvars -a2 words foo bar=ac -v cword 1 -v cur bar=ac
+ ((  10  ))
+ ((  10  ))
+ case $1 in
+ [[ -n 2 ]]
+ printf %d 2
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:2}")'
++ words=("${@:3:2}")
+ shift 4
+ ((  6  ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=1
+ shift 3
+ ((  3  ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=bar=ac
+ shift 3
+ ((  0  ))
+ [[ -n cur ]]
+ upvars+=("$vcur")
+ upargs+=(-v $vcur "$cur")
+ [[ -n cword ]]
+ upvars+=("$vcword")
+ upargs+=(-v $vcword "$cword")
+ [[ -n prev ]]
+ [[ 1 -ge 1 ]]
+ upvars+=("$vprev")
+ upargs+=(-v $vprev "${words[cword - 1]}")
+ [[ -n words ]]
+ upvars+=("$vwords")
+ upargs+=(-a${#words[@]} $vwords "${words[@]}")
+ ((  4  ))
+ local cur cword prev words
+ _upvars -v cur bar=ac -v cword 1 -v prev foo -a2 words foo bar=ac
+ ((  13  ))
+ ((  13  ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=bar=ac
+ shift 3
+ ((  10  ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=1
+ shift 3
+ ((  7  ))
+ case $1 in
+ [[ -n prev ]]
+ unset -v prev
+ eval 'prev="$3"'
++ prev=foo
+ shift 3
+ ((  4  ))
+ case $1 in
+ [[ -n 2 ]]
+ printf %d 2
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:2}")'
++ words=("${@:3:2}")
+ shift 4
+ ((  0  ))
+ _variables
+ [[ bar=ac =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]
+ return 1
+ [[ bar=ac == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ [[ foo == @(?([0-9])<|?([0-9&])>?(>)|>&) ]]
+ local i skip
+ (( i=1 ))
+ (( i < 2 ))
+ [[ bar=ac == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ i=2
+ (( 1 ))
+ (( i < 2 ))
+ [[ 1 -eq 0 ]]
+ prev=foo
+ [[ -n '' ]]
+ return 0
+ case $cur in
+ cur=ac
+ _filedir
+ local i 'IFS=
' xspec
+ _tilde ac
+ local result=0
+ [[ ac == ~* ]]
+ return 0
+ local -a toks
+ local quoted tmp
+ _quote_readline_by_ref ac quoted
+ [[ ac == \'* ]]
+ printf -v quoted %q ac
+ [[ ac == \$* ]]
+ toks=($(
        compgen -d -- "$quoted" | {
            while read -r tmp; do
                # TODO: I have removed a "[ -n $tmp ] &&" before 'printf ..',
                #       and everything works again. If this bug suddenly
                #       appears again (i.e. "cd /b<TAB>" becomes "cd /"),
                #       remember to check for other similar conditionals (here
                #       and _filedir_xspec()). --David
                printf '%s\n' $tmp
            done
        }
    ))
++ compgen -d -- ac
++ read -r tmp
+ [[ '' != -d ]]
+ xspec=
+ toks+=($( compgen -f -X "$xspec" -- $quoted ))
++ compgen -f -X '' -- ac
+ [[ -n '' ]]
+ [[ 1 -ne 0 ]]
+ compopt -o filenames
+ COMPREPLY+=("${toks[@]}")
+ return 0
aclocal.m4

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Bash-completion-devel mailing list
Bash-completion-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/bash-completion-devel

Reply via email to