#1099825 `dpkg -l doesnotexist` runs pager with empty contents, with errors hidden by the pager

Package:
dpkg
Source:
dpkg
Description:
Debian package management system
Submitter:
Josh Triplett
Date:
2025-03-08 15:33:02 UTC
Severity:
normal
#1099825#3
Date:
2025-03-08 15:28:26 UTC
From:
To:
If you run `dpkg -l doesnotexist`, it launches a pager showing
completely empty output, while printing the error
`dpkg-query: no packages found matching doesnotexist`
outside of the pager, hidden until exiting the pager.

`dpkg -l dpkg doesnotexist` will show the output for `dpkg` in the
pager, while showing the error for `doesnotexist` outside the pager.
That's slightly less of an issue because the pager screen isn't
completely blank, but it still doesn't seem ideal.

In the case where there's *zero* output, I think dpkg shouldn't be
launching the pager at all.

In the case where there's *some* output, ideally I'd love to have the
error output sent to the pager as well when automatically launching a
pager, if stdout and stderr are both pointing to a terminal, and only
kept separate when *not* launching a pager or if stderr is going
somewhere else.