[Bash-completion-devel] Bug#463969: bash-completion: The bug seems to still present in 20080617.5

Morita Sho morita-pub-en-debian at inz.sakura.ne.jp
Wed Jun 25 17:52:45 UTC 2008


On 06/26/2008 12:57 AM, David Paleino wrote:
> On Thu, 26 Jun 2008 00:23:46 +0900, Morita Sho wrote:
> 
>> $ gdb traceroute[TAB]
>> => traceroute        traceroute-nanog.db  traceroute6
>> traceroute-nanog     traceroute.db        traceroute6.db
>>
>> $ gdb traceroute-[TAB]
>> => $ gdb traceroute-nanog     Oh my...
>>
>> $ gdb traceroute-2[TAB]
>> => $ gdb traceroute-2.0.11/   I got it!!
>>
>>
>> BTW, can I make a suggestion?
>> I read the code for gdb completion, the _gdb function.
>> It calls compgen -c, I see that is a reason why gdb completes command names.
>> COMPREPLY=( $( compgen -c -- $cur ) )
>>
>> Why not add -d option to compgen?
>> COMPREPLY=( $( compgen -d -c -- $cur ) )
>>
>> I think adding -d option makes gdb completion better, especially on worst
>> case, e.g. "traceroute-[TAB]" in above.
> 
> Agreed, sorry for not thinking at this before :)
> 
> Fixed in bzr.

Thank you for agreed my suggestion.

I have few things that I forgot to say in previous mail.

1) $cur should be surrounded by double quotes, otherwise directory names that 
contain spaces cause a problem.

2) gdb finds a executable for the current directory as well as $PATH. however 
gdb completion does not completes a executable in the current directory.
$ ls
my-program.c
$ gcc -g -o my-program my-program.c
$ gdb my-[TAB]
   => nothing completes.

Put PATH="$PATH:." to the front of compgen command allows compgen to search a 
executable in the current directory.

In conclusion, I suggest following code.
COMPREPLY=( $( PATH="$PATH:." compgen -d -c -- "$cur" ) )


I wanted to fix the problem that gdb completion completes Bash's built-in 
commands, functions and aliases.
but it is slightly hard to implement...

Regards,

-- 
Morita Sho <morita-pub-en-debian at inz.sakura.ne.jp>






More information about the Bash-completion-devel mailing list