Package: dpkg
Version: 1.22.4
Severity: normal

Hey.

dpkg-query manpage says:
EXIT STATUS
       0   The requested query was successfully performed.

       1   The  requested  query  failed  either fully or partially, due to no
           file  or  package   being   found   (except   for   --control-path,
           --control-list and --control-show were such errors are fatal).

       2   Fatal  or unrecoverable error due to invalid command-line usage, or
           interactions with the system, such as  accesses  to  the  database,
           memory allocations, etc.

E.g.:
 $ dpkg-query --showformat='${db:Status-Status}' --show --list 2>/dev/null ; 
echo $?
 2
looks good, as does
 $ dpkg-query --showformat='${db:Status-Status}' --show not-existing-package 
2>/dev/null ; echo $?
 1

But e.g.
 $ dpkg-query --showformat='${db:Status-Statu' --show  2>/dev/null ; echo $?
 1
causes also 1, though it fails because of the syntax error in the format string.

Shouldn't that be a 2?


At least it seems to make it impossible to definitely find out whether a package
is not installed (respectively not existant).


btw. it will also not fail at all in cases like:
 $ dpkg-query --showformat='${db:Status-Statu}' --show  2>/dev/null ; echo $?
 0
where the field doesn't exist. Not sure whether that’s desired or not


Cheers,
Chris.


-- Package-specific info:

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.6.15-amd64 (SMP w/16 CPU threads; PREEMPT)
Locale: LANG=en_DE.UTF-8, LC_CTYPE=en_DE.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages dpkg depends on:
ii  libbz2-1.0   1.0.8-5+b2
ii  libc6        2.37-15
ii  liblzma5     5.4.5-0.3
ii  libmd0       1.1.0-2
ii  libselinux1  3.5-2
ii  libzstd1     1.5.5+dfsg2-2
ii  tar          1.35+dfsg-3
ii  zlib1g       1:1.3.dfsg-3+b1

dpkg recommends no packages.

Versions of packages dpkg suggests:
ii  apt            2.7.11
ii  debsig-verify  0.29

-- no debconf information

Reply via email to