diff options
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageName.pm | 13 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_info | 14 |
2 files changed, 15 insertions, 12 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageName.pm b/usr.sbin/pkg_add/OpenBSD/PackageName.pm index 471f77bc2ae..8aa0baefa73 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageName.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageName.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageName.pm,v 1.16 2007/05/07 13:51:58 espie Exp $ +# $OpenBSD: PackageName.pm,v 1.17 2007/05/07 14:06:38 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -170,6 +170,17 @@ sub findstem my ($self, $stem) = @_; return keys %{$self->{$stem}}; } + +sub find_partialstem +{ + my ($self, $partial) = @_; + my @result = (); + while (my ($stem, $pkgs) = each %$self) { + next unless $stem =~ /\Q$partial\E/i; + push(@result, keys %$pkgs); + } + return @result; +} package OpenBSD::PackageName::version; diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info index 6a49b046eb3..4a00ca14510 100644 --- a/usr.sbin/pkg_add/pkg_info +++ b/usr.sbin/pkg_add/pkg_info @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_info,v 1.45 2007/05/02 13:59:19 espie Exp $ +# $OpenBSD: pkg_info,v 1.46 2007/05/07 14:06:38 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -371,16 +371,8 @@ if ($opt_Q) { my $stemlist = OpenBSD::PackageName::available_stems(); print "PKG_PATH=$ENV{PKG_PATH}\n" if $opt_v; - for my $stem (sort keys %$stemlist) { - if ($stem =~ /\Q$opt_Q\E/i) { - for my $p (keys %{$stemlist->{$stem}}) { - my $text = "$p"; - if (is_installed($p)) { - $text .= " (installed)"; - } - print $text."\n"; - } - } + for my $p (sort $stemlist->find_partialstem($opt_Q)) { + print $p, is_installed($p) ? " (installed)" : "" , "\n"; } exit 0; |