Here's the situation on 7.04.

    $ apt-cache show awk
    $ echo $?
    0
    $ dpkg -p awk
    Package `awk' is not available.
    Use dpkg --info (= dpkg-deb --info) to examine archive files,
    and dpkg --contents (= dpkg-deb --contents) to list their contents.
    $ echo $?
    1
    $ dpkg-query -p awk
    Package `awk' is not available.
    Use dpkg --info (= dpkg-deb --info) to examine archive files,
    and dpkg --contents (= dpkg-deb --contents) to list their contents.
    $ echo $?
    1

apt-cache(8) says:

    show pkg(s)
        show performs a function similar to dpkg --print-avail;  it
        displays the package records for the named packages.

It doesn't state that it will display no output for virtual packages.
(I may not have got the correct term, or covered all the situations
apt-cache remains silent.)  Nor does it say the exit status won't
reflect that the package was a virtual one.

It says it's similar to `dpkg -p' but there's clearly some differences;
dpkg and dpkg-query both complain to stderr and exit(1).  Indeed, they
do these even if some of the packages exist.

    $ dpkg -p awk binutils >1 2>2
    $ echo $?
    1
    $ cat 1

    Package: binutils
    Priority: standard
    Section: devel
    Installed-Size: 7392
    Maintainer: Ubuntu Core Developers <[EMAIL PROTECTED]>
    Architecture: i386
    Version: 2.17.20070103cvs-0ubuntu2
    Provides: elf-binutils
    Depends: libc6 (>= 2.5-0ubuntu1)
    Suggests: binutils-doc (= 2.17.20070103cvs-0ubuntu2)
    Conflicts: gas, elf-binutils, modutils (<< 2.4.19-1)
    Size: 1580378
    Description: The GNU assembler, linker and binary utilities
     The programs in this package are used to assemble, link and manipulate
     binary and object files.  They may be used in conjunction with a compiler
     and various libraries to build programs.
    Original-Maintainer: James Troup <[EMAIL PROTECTED]>
    $ cat 2
    Package `awk' is not available.
    Use dpkg --info (= dpkg-deb --info) to examine archive files,
    and dpkg --contents (= dpkg-deb --contents) to list their contents.
    $

At the very least, apt-cache(8) can be improved.  Otherwise people who
RTFM, like me, will still waste their time investigating what apparently
isn't a bug.  But I think the behaviour of dpkg and dpkg-query argue
that apt-cache should also issue a diagnostic and alter its exit status
to non-zero.  Matt Zimmerman above says

    apt-cache show has a defined output format; it does not carry on a
    plain language dialogue with the user.

What is it that would get upset if apt-cache's behaviour changed?

** Changed in: apt (Ubuntu)
       Status: Fix Released => Confirmed

-- 
`apt-cache show gphoto2' is silent and exits 0.
https://bugs.launchpad.net/bugs/18306
You received this bug notification because you are a member of Ubuntu
Bugs, which is a direct subscriber.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to