On Fri, Nov 10, 2023 at 8:30 PM Morgan Aldridge <morg...@makkintosshu.com>
wrote:

> >Synopsis: pkg_add -IQ does not show single-line comment for packages
> matching query
> >Category: system
> >Environment:
> System      : OpenBSD 7.4
> Details     : OpenBSD 7.4-stable (GENERIC.MP) #0: Sun Oct 29 17:05:47 EDT
> 2023
> linetr...@kuuki.winooski.vt.us.makkintosshu.net:/sys/arch/amd64/compile/
> GENERIC.MP
>
> Architecture: OpenBSD.amd64
> Machine     : amd64
> >Description:
> When using the pkg_info(1)'s '-Q' query option, it only displays the
> package name and, appends " (installed)" if it's already installed.
> There exists a '-I' option which will cause pkg_info(1) to display the
> package name and the one-line comment describing the package.
> Unfortunately, using the '-I' option with the '-Q' option doesn't
> result in the one-line comment being included in the output.
>
> Looking at the implementation of pkg_info(1)'ss '-Q' option in
> usr.sbin/pkg_add/OpenBSD/PkgInfo.pm, specifically handle_query(), it
> calls $self->print_info() if any of the 'cdfMqs' options were provided,
> otherwise just outputs the package name (denoting that it's installed,
> if it is.) Interestingly, parse_and_run() explicitly adds the '-I'
> option if it was not set along with the '-Q' option, but that's not one
> of the options that handle_query() considers when branching into
> print_info().
> >How-To-Repeat:
> $ pkg_info -aQ vwm
> debug-fvwm2-2.7.0
> debug-fvwm3-1.0.8p0
> fvwm2-2.7.0
> fvwm3-1.0.8p0
> mlvwm-0.9.4 (installed)
>
> $ pkg_info -qaQ vwm
> debug-fvwm2-2.7.0
> debug-fvwm3-1.0.8p0
> fvwm2-2.7.0
> fvwm3-1.0.8p0
> mlvwm-0.9.4
>
> $ pkg_info -IaQ vwm
> debug-fvwm2-2.7.0
> debug-fvwm3-1.0.8p0
> fvwm2-2.7.0
> fvwm3-1.0.8p0
> mlvwm-0.9.4 (installed)
> >Fix:
> Untested: change handle_query() in usr.sbin/pkg_add/OpenBSD/PkgInfo.pm
> to include the '-I' option when considering whether to call
> $self->print_info(). This will likely allow the following functionality
> (equivalent to `pkg_info -qaQ vwm | xargs pkg_info -I`):
>
> $ pkg_info -IaQ vwm
> debug-fvwm2-2.7.0   debug info for fvwm2
> debug-fvwm3-1.0.8p0 debug info for fvwm3
> fvwm2-2.7.0         multiple virtual desktop window manager
> fvwm3-1.0.8p0       multiple virtual desktop window manager
> mlvwm-0.9.4         Macintosh-like virtual window manager
>

The attached patch implements the above in a way that supports the current
pkg_info(1) '-Q' functionality and allows combining with '-I'.

Morgan

Attachment: pkg_info-IaQ-support.patch
Description: Binary data

Reply via email to