Re: [BUG][bash][auto completion] if COMPREPLY contents : auto completion doesn't work properly

2006-09-27 Thread Chet Ramey
 I added some echos to the completion function to check, and I see
 something different.

I think you (and the author of the completion function) misinterpreted
the intended results.  The COMP_WORDS array is an array of the words
on the command line, split as the shell would split them during
parsing.  That's intended to allow function writers to see the words
of the command as they would eventually be parsed.  The second
argument to the shell function ($2) is the word being completed, and
that is as readline breaks the words.  The nature of COMP_WORDS isn't
as clear as it could be made in the bash documentation, but that can
be changed. 

Readline's behavior when splitting words for the completer can be intuited
from the difference, if any, between $2 and ${COMP_WORDS[$COMP_CWORD]}.  That
can give the function writer greater context.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong.
Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://tiswww.tis.case.edu/~chet/


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: [BUG][bash][auto completion] if COMPREPLY contents : auto completion doesn't work properly

2006-09-26 Thread Chet Ramey
Vasily Tarasov wrote:

 I suppose I've found a bug;

I need to make this part of the FAQ.  The `:' is special to readline:  it
splits words for the word completion code.

The default set of such characters is available in the COMP_WORDBREAKS
variable.  Removing `:' from the value of that variable should produce
the behavior you want.

Something like

COMP_WORDBREAKS=${COMP_WORDBREAKS//:}

will do the job.

Chet


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: [BUG][bash][auto completion] if COMPREPLY contents : auto completion doesn't work properly

2006-09-26 Thread Paul Jarc
Chet Ramey [EMAIL PROTECTED] wrote:
 Vasily Tarasov wrote:

 I suppose I've found a bug;

 I need to make this part of the FAQ.  The `:' is special to readline:  it
 splits words for the word completion code.

That explains some of what's going on in this case, but not all.  For
the first tab, shouldn't the text filled in by completion be qwe\:o
instead of qwe:o, since it includes a COMP_WORDBREAKS character?
That's how filename completion behaves, so I'd expect the same
behavior here.  Is the completion function responsible for adding the
backslash, or should bash do it?

Also, after two tabs, we have qwe:qwe:o, but further tabs don't add
any more qwe:'s for some reason I don't understand.


paul


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: [BUG][bash][auto completion] if COMPREPLY contents : auto completion doesn't work properly

2006-09-26 Thread Chet Ramey
 Chet Ramey [EMAIL PROTECTED] wrote:
  Vasily Tarasov wrote:
 
  I suppose I've found a bug;
 
  I need to make this part of the FAQ.  The `:' is special to readline:  it
  splits words for the word completion code.
 
 That explains some of what's going on in this case, but not all.  For
 the first tab, shouldn't the text filled in by completion be qwe\:o
 instead of qwe:o, since it includes a COMP_WORDBREAKS character?
 That's how filename completion behaves, so I'd expect the same
 behavior here.  Is the completion function responsible for adding the
 backslash, or should bash do it?

The backslash addition is a feature of filename completion, and bash's
default word completion.  There isn't a really good way to have such
quotes stripped before handing the word to the completion function, nor
is there a specific option to have filename-like quoting applied to the
result (though the completion function can always add the backslash).

 Also, after two tabs, we have qwe:qwe:o, but further tabs don't add
 any more qwe:'s for some reason I don't understand.

Because the colon is still a word break character, and readline passes `o'
to the completion function as the partial word to be completed.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong.
Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://tiswww.tis.case.edu/~chet/


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: [BUG][bash][auto completion] if COMPREPLY contents : auto completion doesn't work properly

2006-09-26 Thread Paul Jarc
Chet Ramey [EMAIL PROTECTED] wrote:
 Chet Ramey [EMAIL PROTECTED] wrote:
 Also, after two tabs, we have qwe:qwe:o, but further tabs don't add
 any more qwe:'s for some reason I don't understand.

 Because the colon is still a word break character, and readline passes `o'
 to the completion function as the partial word to be completed.

I added some echos to the completion function to check, and I see
something different.

$ echo $COMP_WORDBREAKS
 
'=;|(:
$ _myfunc() {
   local cur=${COMP_WORDS[COMP_CWORD]}
   COMPREPLY=( $(compgen -W qwe:on qwe:off -- $cur) )
   echo
   echo
   printf '%s\n' cword $cur words [EMAIL PROTECTED] reply [EMAIL 
 PROTECTED]
   echo
 }
$ complete -F _myfunc myfunc
$ myfunc TAB

cword

words
myfunc

reply
qwe:on
qwe:off

$ myfunc qwe:oTAB

cword
qwe:o
words
myfunc
qwe:o
reply
qwe:on
qwe:off

$ myfunc qwe:qwe:oTAB

cword
qwe:qwe:o
words
myfunc
qwe:qwe:o
reply

So it looks like the entire word is passed to the completion function;
COMP_WORDBREAKS is not consulted at that point.  COMP_WORDBREAKS is
only used to decide how much text to erase before inserting the
completion text.  Is that intended?  Is the completion function
supposed to take care of splitting the word if it wants that?


paul


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: [BUG][bash][auto completion] if COMPREPLY contents : auto completion doesn't work properly

2006-09-26 Thread Chet Ramey
 So it looks like the entire word is passed to the completion function;
 COMP_WORDBREAKS is not consulted at that point.  COMP_WORDBREAKS is
 only used to decide how much text to erase before inserting the
 completion text.  Is that intended?  Is the completion function
 supposed to take care of splitting the word if it wants that?

If that's the case, my memory is faulty.  My fault for not checking.  I'll
have to look at the code.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong.
Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://tiswww.tis.case.edu/~chet/


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


[BUG][bash][auto completion] if COMPREPLY contents : auto completion doesn't work properly

2006-09-23 Thread Vasily Tarasov
Hello all,

I suppose I've found a bug;
My bash version:
GNU bash, version 3.00.15(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
But I also have downloaded bash 3.1 and this bug is reproducible there to.

Actions to reproduce:
1) Create the file test.sh, that contents:

_myfunc()
{
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W qwe:on qwe:off -- $cur) )
}

complete -F _myfunc myfunc

2) Apply this file to the following bash environment:
. ./test.sh

3) Let's try it:
[EMAIL PROTECTED] $ myfunc
Press tab once:
[EMAIL PROTECTED] $ myfunc qwe:o
Press tab secondary:
[EMAIL PROTECTED] $ myfunc qwe:qwe:o


Note, that if ': is replaced by something else, for exampe '!'
everything works:
[EMAIL PROTECTED] $ myfunc qwe!o
qwe!off  qwe!on
[EMAIL PROTECTED] $ myfunc qwe!off

Please, tell me is it a BUG? If it is  - will it be fixed, where I can
follow the progress (I've found no bugzilla for bash)?
If it isn't a bug, please, advice me a workaround.

Thanks for your work,
Vasily Tarasov.













___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash