[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 19:13:57 UTC 2008
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
-------------- 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/b970c1ce/attachment.pgp
More information about the Bash-completion-devel
mailing list