Thanks for taking the time to report this issue! However, it seems to be
explained in the man page of apt-cache. Some background information:
/etc/bash_completion.d/apt uses the following line to generate the packagenames:
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
>From the manpage of apt-cache:
pkgnames [ prefix ]
This command prints the name of each package APT knows. The
optional argument is a prefix match to filter the name list. The
output is suitable for use in a shell tab complete function and the
output is generated extremely quickly. This command is best used
with the --generate option.
Note that a package which APT knows of is not necessarily available
to download, installable or installed, e.g. virtual packages are
also listed in the generated list.
I tried to check if a package can be installed via a shellscript, but run time
is limiting, for completeness here's the script I tested:
#!/bin/bash
pkgs=$(apt-cache pkgnames python2)
for pkg in $pkgs
do
cand=$(apt-cache policy $pkg | grep Candidate)
if [[ "$cand" =~ "Candidate: (none)" ]]
then
uninstallable="$uninstallable $pkg"
else
installable="$installable $pkg"
fi
done
echo $installable
It seems the best solution would be to modify apt-cache and maybe add an
option '--installable' to the pkgname argument to only show packages
that have a candidate.
** Changed in: apt (Ubuntu)
Status: New => Confirmed
** Changed in: apt (Ubuntu)
Importance: Undecided => Wishlist
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/600463
Title:
Bash auto-completion for apt-get & aptitude shows non-existent
packages
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs