Debian Bug report logs -
#463969
bash completion for gdb doesn't work on filenames
Reported by: Reuben Thomas <rrt@sc3d.org>
Date: Mon, 4 Feb 2008 12:12:04 UTC
Severity: normal
Tags: unreproducible
Found in version bash-completion/20080617.5
Fixed in versions 20080617.1, bash-completion/20080705
Done: Luk Claes <luk@debian.org>
Bug is archived. No further changes may be made.
Toggle useless messages
Report forwarded to debian-bugs-dist@lists.debian.org, Matthias Klose <doko@debian.org>:
Bug#463969; Package bash.
(full text, mbox, link).
Acknowledgement sent to Reuben Thomas <rrt@sc3d.org>:
New Bug report received and forwarded. Copy sent to Matthias Klose <doko@debian.org>.
(full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: bash
Version: 3.1dfsg-8
Severity: normal
If I type "gdb sr<TAB>" to try to complete "src/", it doesn't work
(nothing happens).
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (700, 'testing'), (601, 'unstable'), (600, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.24-1-686 (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages bash depends on:
ii base-files 4.0.2 Debian base system miscellaneous f
ii debianutils 2.28.2 Miscellaneous utilities specific t
ii libc6 2.7-6 GNU C Library: Shared libraries
ii libncurses5 5.6+20080105-1 Shared libraries for terminal hand
bash recommends no packages.
-- no debconf information
Bug reassigned from package `bash' to `bash-completion'.
Request was from Luk Claes <luk@debian.org>
to control@bugs.debian.org.
(Sun, 02 Mar 2008 15:24:13 GMT) (full text, mbox, link).
Tags added: unreproducible
Request was from David Paleino <d.paleino@gmail.com>
to control@bugs.debian.org.
(Sun, 11 May 2008 15:00:02 GMT) (full text, mbox, link).
Acknowledgement sent to David Paleino <d.paleino@gmail.com>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #14 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
tags 463969 unreproducible
thanks
Hi Reuben,
On Mon, 04 Feb 2008 12:08:01 +0000, Reuben Thomas wrote:
> If I type "gdb sr<TAB>" to try to complete "src/", it doesn't work
It works for me:
$ cd /
$ gdb bin[TAB]
bin/ bind
$ gdb bin/e[TAB]
$ gdb bin/echo
GNU gdb 6.8-debian
[..]
Please check if you have bash-completion installed (yes, that's the package
name!) :)
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
[signature.asc (application/pgp-signature, attachment)]
Acknowledgement sent to Reuben Thomas <rrt@sc3d.org>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #19 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
On Sun, 11 May 2008, David Paleino wrote:
> tags 463969 unreproducible
> thanks
>
> Hi Reuben,
>
> On Mon, 04 Feb 2008 12:08:01 +0000, Reuben Thomas wrote:
>
>> If I type "gdb sr<TAB>" to try to complete "src/", it doesn't work
>
> It works for me:
>
> $ cd /
> $ gdb bin[TAB]
> bin/ bind
> $ gdb bin/e[TAB]
> $ gdb bin/echo
> GNU gdb 6.8-debian
> [..]
This works for me. However,
$ cd /usr
$ gdb src[TAB]
[no response]
> Please check if you have bash-completion installed (yes, that's the package
> name!) :)
I do.
--
http://rrt.sc3d.org/ | Travail broadens the behind
Acknowledgement sent to David Paleino <d.paleino@gmail.com>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #24 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
On Mon, 12 May 2008 21:45:05 +0100 (BST), Reuben Thomas wrote:
> On Sun, 11 May 2008, David Paleino wrote:
>
> > It works for me:
> >
> > [..]
>
> This works for me. However,
>
> $ cd /usr
> $ gdb src[TAB]
> [no response]
Still unreproducible here, sorry:
$ cp /bin/echo /usr/src/
$ cd /usr/
$ gdb src[TAB]
$ gdb src/
$ gdb src/e[TAB]
$ gdb src/echo
GNU gdb 6.8-debian
[..]
> > Please check if you have bash-completion installed (yes, that's the package
> > name!) :)
>
> I do.
I'm sorry if that seemed like a joke -- it's just that bash-completion has been
recently split from bash -- it might be not installed.
Would you please report the output of:
$ grep "\$Id:" /etc/bash_completion
Thanks,
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
[signature.asc (application/pgp-signature, attachment)]
Acknowledgement sent to Reuben Thomas <rrt@sc3d.org>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #29 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
On Fri, 16 May 2008, David Paleino wrote:
> I'm sorry if that seemed like a joke -- it's just that bash-completion has been
> recently split from bash -- it might be not installed.
No, I remembered something along those lines.
> $ grep "\$Id:" /etc/bash_completion
# $Id: bash_completion,v 1.872 2006/03/01 16:20:18 ianmacd Exp $
Acknowledgement sent to David Paleino <d.paleino@gmail.com>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #34 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
(no need to CC me, thanks :)
On Sat, 17 May 2008 17:41:10 +0100 (BST), Reuben Thomas wrote:
> On Fri, 16 May 2008, David Paleino wrote:
>
> > $ grep "\$Id:" /etc/bash_completion
>
> # $Id: bash_completion,v 1.872 2006/03/01 16:20:18 ianmacd Exp $
This is the exact same version I currently have installed (besides the
development one). I suspect that some of the "development" functions have
"infected" my environment -- could you please test whether this happens with
our current version in bzr? Just extract the attachment and put it into /etc/.
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
[bash_completion.bz2 (application/x-bzip, attachment)]
[signature.asc (application/pgp-signature, attachment)]
Acknowledgement sent to Reuben Thomas <rrt@sc3d.org>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #39 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
On Sat, 17 May 2008, David Paleino wrote:
> (no need to CC me, thanks :)
I just reply to all recipients.
> This is the exact same version I currently have installed (besides the
> development one). I suspect that some of the "development" functions have
> "infected" my environment -- could you please test whether this happens
> with our current version in bzr? Just extract the attachment and put it
> into /etc/.
bash: /etc/bash_completion: line 9338: unexpected EOF while looking for
matching ``'
bash: /etc/bash_completion: line 9397: syntax error: unexpected end of file
Completion then works as expected for gdb but I don't know if the
completions were properly loaded...
--
http://rrt.sc3d.org/ | fantasize, a. the largest you can imagine
Bug marked as fixed in version 20080617.1, send any further explanations to Reuben Thomas <rrt@sc3d.org>
Request was from Luk Claes <luk@debian.org>
to control@bugs.debian.org.
(Tue, 24 Jun 2008 17:39:09 GMT) (full text, mbox, link).
Information forwarded to debian-bugs-dist@lists.debian.org, Bash Completion Maintainers <bash-completion-devel@lists.debian.org>:
Bug#463969; Package bash-completion.
(full text, mbox, link).
Acknowledgement sent to Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>:
Extra info received and forwarded to list. Copy sent to Bash Completion Maintainers <bash-completion-devel@lists.debian.org>.
(full text, mbox, link).
Message #46 received at 463969@bugs.debian.org (full text, mbox, reply):
Package: bash-completion
Version: 20080617.5
Followup-For: Bug #463969
Hi,
I'm interesting this bug because I have the same problem.
The bug has been marked as fixed in version 20080617.1,
but it seems to still present.
$ mkdir foobar
$ ls
foobar
$ gdb foob[TAB]
=> does not complete "foobar"
Regards,
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.25-2-686 (SMP w/1 CPU core)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages bash-completion depends on:
ii bash 3.2-4 The GNU Bourne Again SHell
ii ucf 3.007 Update Configuration File: preserv
bash-completion recommends no packages.
-- no debconf information
Bug marked as found in version 20080617.5 and reopened.
Request was from David Paleino <d.paleino@gmail.com>
to control@bugs.debian.org.
(Wed, 25 Jun 2008 06:54:02 GMT) (full text, mbox, link).
Acknowledgement sent to David Paleino <d.paleino@gmail.com>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #53 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
On Wed, 25 Jun 2008 14:45:10 +0900, Morita Sho wrote:
> Package: bash-completion
> Version: 20080617.5
> Followup-For: Bug #463969
>
> Hi,
Hello,
> I'm interesting this bug because I have the same problem.
> The bug has been marked as fixed in version 20080617.1,
> but it seems to still present.
>
> $ mkdir foobar
> $ ls
> foobar
> $ gdb foob[TAB]
> => does not complete "foobar"
This seemed to be intended:
complete -F _gdb $filenames gdb
Changing it to:
complete -F _gdb $default gdb
Seems to solve it.
I've committed the change to our repository, but I'm not sure when the new
version will be released.
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
[signature.asc (application/pgp-signature, attachment)]
Acknowledgement sent to Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #58 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
On 06/25/2008 03:59 PM, David Paleino wrote:
> This seemed to be intended:
>
> complete -F _gdb $filenames gdb
>
> Changing it to:
>
> complete -F _gdb $default gdb
>
> Seems to solve it.
> I've committed the change to our repository, but I'm not sure when the new
> version will be released.
Thank you.
gdb completion now completes "foob[TAB]" to "foobar" as I expected.
However it still not work in following case.
$ mkdir sourcecode
$ ls
sourcecode
$ gdb sour[TAB]
=> completes "source". I want to complete "sourcecode".
It seems the completion does not work as expected when the completing word
matches any command name. ("source" is a bash's builtin command.)
Regards,
--
Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>
Acknowledgement sent to David Paleino <d.paleino@gmail.com>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #63 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
On Wed, 25 Jun 2008 21:23:10 +0900, Morita Sho wrote:
> Thank you.
> gdb completion now completes "foob[TAB]" to "foobar" as I expected.
>
> However it still not work in following case.
>
> $ mkdir sourcecode
> $ ls
> sourcecode
> $ gdb sour[TAB]
> => completes "source". I want to complete "sourcecode".
>
> It seems the completion does not work as expected when the completing word
> matches any command name. ("source" is a bash's builtin command.)
This is how gdb completion is intended to work -- commands have precedence over
anything else. It's more common doing:
$ gdb <command in $PATH>
than
$ gdb <directory with a name starting with the same letters as [..]>
I hope you get my point.
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
[signature.asc (application/pgp-signature, attachment)]
Acknowledgement sent to Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #68 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
On 06/25/2008 09:27 PM, David Paleino wrote:
> This is how gdb completion is intended to work -- commands have precedence over
> anything else. It's more common doing:
>
> $ gdb <command in $PATH>
>
> than
>
> $ gdb <directory with a name starting with the same letters as [..]>
>
> I hope you get my point.
Thanks for your quick response.
I know what you mean, but IMHO
* gdb completion should not completes non existing program name. (e.g. Bash's
built-in command names.)
* gdb completion should ALSO completes directory names.
I agree that executing gdb for command in $PATH is common usage.
However it is also common that executing gdb for programs under the current
directory.
For example, recently I run gdb for traceroute that locally built with a debug
symbols as follow:
$ apt-get source traceroute
[..]
$ gdb traceroute-2.0.11/traceroute/traceroute
If gdb does not complete directory names, I need to type "traceroute-2.0.11" by
hand. It's very inconvenient.
Therefore, I think it would be better if gdb completes directory names as well
as command names.
Regards,
--
Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>
Acknowledgement sent to David Paleino <d.paleino@gmail.com>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #73 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
On Wed, 25 Jun 2008 22:51:54 +0900, Morita Sho wrote:
> On 06/25/2008 09:27 PM, David Paleino wrote:
> > This is how gdb completion is intended to work -- commands have precedence
> > over anything else. It's more common doing:
> >
> > $ gdb <command in $PATH>
> >
> > than
> >
> > $ gdb <directory with a name starting with the same letters as [..]>
> >
> > I hope you get my point.
>
> Thanks for your quick response.
>
> I know what you mean, but IMHO
> * gdb completion should not completes non existing program name. (e.g. Bash's
> built-in command names.)
> * gdb completion should ALSO completes directory names.
It ALSO completes directory names. But commands in $PATH have precedence, so I
can't do anything about this.
> I agree that executing gdb for command in $PATH is common usage.
> However it is also common that executing gdb for programs under the current
> directory.
> For example, recently I run gdb for traceroute that locally built with a
> debug symbols as follow:
> $ apt-get source traceroute
> [..]
> $ gdb traceroute-2.0.11/traceroute/traceroute
>
> If gdb does not complete directory names, I need to type "traceroute-2.0.11"
> by hand. It's very inconvenient.
GDB *does* complete directory names. The unfortunate case is having a directory
name which starts the same as a $PATH command.
> Therefore, I think it would be better if gdb completes directory names as
> well as command names.
Again, it does. Just that command names take precedence.
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
[signature.asc (application/pgp-signature, attachment)]
Acknowledgement sent to Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #78 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
On 06/25/2008 11:10 PM, David Paleino wrote:
>> I know what you mean, but IMHO
>> * gdb completion should not completes non existing program name. (e.g. Bash's
>> built-in command names.)
>> * gdb completion should ALSO completes directory names.
>
> It ALSO completes directory names. But commands in $PATH have precedence, so I
> can't do anything about this.
>
>> I agree that executing gdb for command in $PATH is common usage.
>> However it is also common that executing gdb for programs under the current
>> directory.
>> For example, recently I run gdb for traceroute that locally built with a
>> debug symbols as follow:
>> $ apt-get source traceroute
>> [..]
>> $ gdb traceroute-2.0.11/traceroute/traceroute
>>
>> If gdb does not complete directory names, I need to type "traceroute-2.0.11"
>> by hand. It's very inconvenient.
>
> GDB *does* complete directory names. The unfortunate case is having a directory
> name which starts the same as a $PATH command.
>
>> Therefore, I think it would be better if gdb completes directory names as
>> well as command names.
>
> Again, it does. Just that command names take precedence.
At long last, I have understand what you mean.
Thanks a lot for your explanation!
$ ls
traceroute-2.0.11
$ gdb trace[TAB]
=> traceproto traceroute-nanog.db tracert
traceproto.db traceroute.db tracert.db
traceroute traceroute6
traceroute-nanog traceroute6.db
$ 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.
Currently, the list of the possible completions does not contain directory
names. It confuses users and menu-completion in readline.
Adding -d option can also helps such cases.
Regards,
--
Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>
Acknowledgement sent to David Paleino <d.paleino@gmail.com>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #83 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
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.
Thanks,
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
[signature.asc (application/pgp-signature, attachment)]
Acknowledgement sent to Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #88 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
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@inz.sakura.ne.jp>
Acknowledgement sent to David Paleino <d.paleino@gmail.com>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #93 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
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
[signature.asc (application/pgp-signature, attachment)]
Acknowledgement sent to Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #98 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
On 06/26/2008 02:58 AM, David Paleino wrote:
> On Thu, 26 Jun 2008 02:52:45 +0900, Morita Sho wrote:
>> 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 :)
Exactly. But I made it. :)
If $cur contains any slashes, compgen -c just completes only executables and
directory names. No need to taking care of Bash's built-ins.
The problem is when $cur contains no slashes. I need to get only program names.
To solve this problem, I chosen to use find(1). find(1) can be used to retrieve
program names in the current directory and $PATH.
[...]
if [ $COMP_CWORD -eq 1 ]; then
local IFS
if [[ "$cur" == */* ]]; then
# compgen -c works as expected if $cur contains any slashes.
IFS=$'\n'
COMPREPLY=( $( compgen -d -c -- "$cur" ) )
else
# otherwise compgen -c contains Bash's built-in commands, functions and
aliases.
# Thus we need to retrieve program names manually.
IFS=":"
local path_array=( $(echo "$PATH") )
IFS=$'\n'
COMPREPLY=( $( compgen -d -W '$(find "${path_array[@]}" . \
-mindepth 1 -maxdepth 1 -not -type d -executable -printf "%f\\n")' --
"$cur" ) )
fi
elif [ $COMP_CWORD -eq 2 ]; then
[...]
Regards,
--
Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>
Acknowledgement sent to David Paleino <d.paleino@gmail.com>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #103 received at 463969-quiet@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
On Thu, 26 Jun 2008 04:07:10 +0900, Morita Sho wrote:
> The problem is when $cur contains no slashes. I need to get only program
> names. To solve this problem, I chosen to use find(1). find(1) can be used to
> retrieve program names in the current directory and $PATH.
>
> [...]
> if [ $COMP_CWORD -eq 1 ]; then
> local IFS
> if [[ "$cur" == */* ]]; then
> # compgen -c works as expected if $cur contains any slashes.
> IFS=$'\n'
> COMPREPLY=( $( compgen -d -c -- "$cur" ) )
> else
> # otherwise compgen -c contains Bash's built-in commands, functions
> and aliases.
> # Thus we need to retrieve program names manually.
> IFS=":"
> local path_array=( $(echo "$PATH") )
> IFS=$'\n'
> COMPREPLY=( $( compgen -d -W '$(find "${path_array[@]}" . \
> -mindepth 1 -maxdepth 1 -not -type d -executable -printf "%f\\n")'
> -- "$cur" ) )
> fi
> elif [ $COMP_CWORD -eq 2 ]; then
> [...]
I haven't tested it, but it should work (and I'm confident you tested it ;) )
Anyway, using find, seems a hack to me. While find(1) is always present in
Debian systems (because findutils is a Priority: required package), we are also
upstream for bash-completion, and I have no idea whether find will be *always*
present in any Linux/Hurd/BSD distribution having bash (and, thus, able to have
bash-completion as well).
I'll commit the code, but please be warned that it might be removed in future,
if !Linux (or !Debian) users will complain :)
Thanks the good job,
David (I admit I haven't looked at the code since my last mail... :p)
--
. ''`. 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
[signature.asc (application/pgp-signature, attachment)]
Reply sent to Luk Claes <luk@debian.org>:
You have taken responsibility.
(full text, mbox, link).
Notification sent to Reuben Thomas <rrt@sc3d.org>:
Bug acknowledged by developer.
(full text, mbox, link).
Message #108 received at 463969-close@bugs.debian.org (full text, mbox, reply):
Source: bash-completion
Source-Version: 20080705
We believe that the bug you reported is fixed in the latest version of
bash-completion, which is due to be installed in the Debian FTP archive:
bash-completion_20080705.dsc
to pool/main/b/bash-completion/bash-completion_20080705.dsc
bash-completion_20080705.tar.gz
to pool/main/b/bash-completion/bash-completion_20080705.tar.gz
bash-completion_20080705_all.deb
to pool/main/b/bash-completion/bash-completion_20080705_all.deb
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 463969@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Luk Claes <luk@debian.org> (supplier of updated bash-completion package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Format: 1.8
Date: Sat, 05 Jul 2008 16:14:15 +0200
Source: bash-completion
Binary: bash-completion
Architecture: source all
Version: 20080705
Distribution: unstable
Urgency: low
Maintainer: Bash Completion Maintainers <bash-completion-devel@lists.alioth.debian.org>
Changed-By: Luk Claes <luk@debian.org>
Description:
bash-completion - programmable completion for the bash shell
Closes: 463969 487786 487825 488171
Changes:
bash-completion (20080705) unstable; urgency=low
.
[ David Paleino ]
* Added more completions to imagemagick (thanks to Nelson A. de
Oliveira) (Closes: #487786)
* Added xrandr completion (thanks to Anton Khirnov) (Closes: #487825)
* Improving _gdb completion:
- $filenames to $default (Closes: #463969)
- also show directory names (i.e. compgen -d) in COMPREPLY.
- added . to $PATH, to allow debugging "local" executables.
- do not complete Bash's builtins (thanks to Morita Sho)
.
[ Luk Claes ]
* Remove use of ucf for /etc/bash-completion (Closes: #488171).
Checksums-Sha1:
d30c5f40a1a7f1d53a9c7fa9e5499c796a6cfdcc 870 bash-completion_20080705.dsc
f3713688323722da7e6c5678654e08bd369a29d7 101845 bash-completion_20080705.tar.gz
4a984c3db151bab32d03ca7c7122ecc276571a1f 89202 bash-completion_20080705_all.deb
Checksums-Sha256:
1dc9dede10cab55fdb4349d8fe6306533d1ba56b72d6617ddf9e37da475fb74b 870 bash-completion_20080705.dsc
feb9bffeefacf76431293818683f77f54b9205a1598316a38152bff3ca7d6895 101845 bash-completion_20080705.tar.gz
8a6280103e49a9d422f9488b2c4cd5883455188791233b936634243a94cab18b 89202 bash-completion_20080705_all.deb
Files:
6a82c68d2f19677a385da79e64215b0e 870 shells standard bash-completion_20080705.dsc
8bc36281bb0567bc67a9083c4c5595a9 101845 shells standard bash-completion_20080705.tar.gz
9dca889fbcbff51938fe4dc77cba5ddc 89202 shells standard bash-completion_20080705_all.deb
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkhvhvMACgkQ5UTeB5t8Mo1eXACcCLfvt8ccgjxQR8pS4JR8w9Xe
fpMAoJOc78dH44yDFuG3zdmOZkLrmCn+
=wz/I
-----END PGP SIGNATURE-----
Information forwarded to debian-bugs-dist@lists.debian.org, Bash Completion Maintainers <bash-completion-devel@lists.alioth.debian.org>:
Bug#463969; Package bash-completion.
(full text, mbox, link).
Acknowledgement sent to Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>:
Extra info received and forwarded to list. Copy sent to Bash Completion Maintainers <bash-completion-devel@lists.alioth.debian.org>.
(full text, mbox, link).
Message #113 received at 463969@bugs.debian.org (full text, mbox, reply):
> bash-completion (20080705) unstable; urgency=low
[..]
> - $filenames to $default (Closes: #463969)
> - also show directory names (i.e. compgen -d) in COMPREPLY.
Oops!
I should have explained clearly about this...
"compgen -d" adds directories explicitly, thus it is unnecessary to use $default.
Moreover, $filenames is required to allow the completion for directories appends
'/' automatically.
Could you please revert to $filenames?
--- bash_completion.orig 2008-07-07 14:07:28.000000000 +0900
+++ bash_completion 2008-07-07 14:07:46.000000000 +0900
@@ -4068,7 +4068,7 @@
-- "$cur" ) )
fi
} &&
-complete -F _gdb $default gdb
+complete -F _gdb $filenames gdb
# Postgresql completion
#
Regards,
--
Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp>
Bug archived.
Request was from Debbugs Internal Request <owner@bugs.debian.org>
to internal_control@bugs.debian.org.
(Thu, 14 Aug 2008 07:32:57 GMT) (full text, mbox, link).
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Sun Jul 2 09:14:10 2023;
Machine Name:
buxtehude
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.