summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/pkg_info
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-01-05 12:20:48 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-01-05 12:20:48 +0000
commit1a02a5c913ffadbcacaebb4713b0ea255c42f568 (patch)
tree45aea285b876558925baabfca342e411f25f26dd /usr.sbin/pkg_add/pkg_info
parent723d25dd71d2787a0ec8a189ee7330c5374f729b (diff)
better spec handling: instead of dying, create badspec objects that never
match anything. Add method is_valid (and propagators) to know whether a spec is valid (to be used in pkg_create in a systematic way).
Diffstat (limited to 'usr.sbin/pkg_add/pkg_info')
-rw-r--r--usr.sbin/pkg_add/pkg_info12
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info
index 9cabcb4a973..a6be189d756 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.83 2010/01/02 12:52:18 espie Exp $
+# $OpenBSD: pkg_info,v 1.84 2010/01/05 12:20:47 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -163,9 +163,15 @@ sub find_by_spec
require OpenBSD::Search;
require OpenBSD::PackageRepository::Installed;
- my $r = OpenBSD::PackageRepository::Installed->new->match_locations(OpenBSD::Search::PkgSpec->new($pat));
+ my $s = OpenBSD::Search::PkgSpec->new($pat);
+ if (!$s->is_valid) {
+ print STDERR "Invalid spec: $pat\n";
+ return ();
+ } else {
+ my $r = OpenBSD::PackageRepository::Installed->new->match_locations($s);
- return sort (map {$_->name} @$r);
+ return sort (map {$_->name} @$r);
+ }
}
sub filter_files