On Sat, Nov 11, 2023 at 9:05 PM Morgan Aldridge <morg...@makkintosshu.com> wrote: > > 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'.
My apologies for not inlining the proposed patch. Morgan Index: PkgInfo.pm =================================================================== RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm,v retrieving revision 1.52 diff -u -p -r1.52 PkgInfo.pm --- PkgInfo.pm 14 Jun 2023 09:59:09 -0000 1.52 +++ PkgInfo.pm 12 Nov 2023 01:54:01 -0000 @@ -494,7 +494,7 @@ sub handle_query($self, $state) for my $pkg (sort {$a->name cmp $b->name} @$r) { my $p = $pkg->name; - if ($state->hasanyopt('cdfMqs')) { + if ($state->hasanyopt('cdfIMqs')) { $self->print_info($state, $p, $pkg); } else { $state->say( @@ -573,9 +573,7 @@ sub parse_and_run($self, $cmd) unless ($state->hasanyopt('cMUdfILRsSP') || $state->{terse}) { if ($nonames) { - if ($state->opt('Q')) { - $state->setopts('I'); - } else { + unless ($state->opt('Q')) { $state->setopts('Ia'); } } else {