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

David Paleino d.paleino at gmail.com
Wed Jun 25 17:58:35 UTC 2008


On Thu, 26 Jun 2008 02:52:45 +0900, Morita Sho wrote:

> 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.

I forgot it, thanks! :)

> 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" ) )

Ok, done.

> 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...

Yes :)
The fact is, you can't "exclude" completions from "compgen". Look at the "-b"
switch (or -A builtin, it's the same). There should be something like:

compgen -c !-b [..]

(i.e. complete commands but not bash builtins...)

I'll think a bit about this -- but I won't go mad since it would be a minor
feature, really :)

Kindly,
David

-- 
 . ''`.  Debian maintainer | http://wiki.debian.org/DavidPaleino
 : :'  : Linuxer #334216 --|-- http://www.hanskalabs.net/
 `. `'`  GPG: 1392B174 ----|---- http://snipr.com/qa_page
   `-   2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20080625/365bdd4c/attachment.pgp 


More information about the Bash-completion-devel mailing list