Bug 233304 - ports-mgmt/pkg info -q package doesn't work
Summary: ports-mgmt/pkg info -q package doesn't work
Status: Closed Feedback Timeout
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Bugmeister
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-18 23:03 UTC by freebsd
Modified: 2025-11-16 01:16 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (pkg)


Attachments
manpage (1.81 KB, text/plain)
2025-01-22 15:25 UTC, Dave Cottlehuber
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description freebsd 2018-11-18 23:03:15 UTC
pkg info -q -a 
  gives a list of all installed packages, without descriptions (correct)
pkg info bash
  gives full info for whichever version of bash is installed
pkg info -q bash
  shows nothing
  it should show full version of installed package, as in the -1 -a output
Comment 1 Walter Schwarzenfeld 2019-08-14 17:12:02 UTC
pkg info -q can used like

pkg info -q > packagelist.txt.
Comment 2 freebsd 2019-08-14 18:15:01 UTC
I am reopening this because:

pkg help info shows:
       pkg info [-AbBDdefIklOpqRrs] [-Cgix] pkg-name

That means one should be able to give:
  pkg info -q bash
or 
  pkg info -q bash-4.4.23_1

Neither of which works.

While one can clearly do
  pkg info -q | grep bash
to get the desired result, either the pkg command is not working as documented and needs fixing, or the documentation needs to be fixed to reflect how the command actually works.
Comment 3 Walter Schwarzenfeld 2019-08-14 22:47:49 UTC
It works in combination with other switches:

pkg info -qo firefox
www/firefox

pkg info -qR firefox
displays the full Manifest

pkg info -qf firefox

the normal pkg info firefox output
Comment 4 freebsd 2019-08-15 05:18:38 UTC
> It works in combination with other switches:
>
> pkg info -qo firefox
> www/firefox

In that case, it *should* work by itself, as documented.

It seems rather bizarre behavior in terms of code to have it work in combination with other flags with a filename argument, but not alone; yet work alone with no filename argument.

It looks to me like the query_flags will be empty with only -q present, as it is taken out with the "quiet" flag, and pkgdb_it_next probably does not return EPKG_OK (about line 448 in info.c).
Comment 5 Baptiste Daroussin freebsd_committer freebsd_triage 2025-01-22 14:02:34 UTC
the logic is inheritted from the historical behaviour of pkg_info and can be revisited.

the logic as I understood when I had to implement it is:

pkg info <somthing> query if that thing exists, so it shows some output if yes (and I mimic pkg_info output) and nothing not with the return error code 0 or 1. so if you add '-q' then you end up with no output at all and the same error code

-o request an explicit information, so it always prints it, same for -f
-a do request everything to be printed.

again I can revisit this logic this is very simple code to change.
Comment 6 Dave Cottlehuber freebsd_committer freebsd_triage 2025-01-22 15:25:07 UTC
Created attachment 256905 [details]
manpage

discussed on IRC.

- changing pkg-info behaviour is likely to break no matter which way its changed
- improve documentation to clarify why pkg-info(8) sometimes prints output, or not
Comment 7 Mark Linimon freebsd_committer freebsd_triage 2025-03-09 14:48:50 UTC
Comment on attachment 256905 [details]
manpage

^Triage: to patch submitter: Bugzilla cannot recognize this as a patch.
Can you resubmit without the formatting, please?
Comment 8 Mark Linimon freebsd_committer freebsd_triage 2025-11-16 01:16:36 UTC
^Triage: feedback timeout (> 6 months).