summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-11-11 11:17:12 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-11-11 11:17:12 +0000
commitff6780c1ae7637bd22cd6c04ea140e97df7585af (patch)
treefceb42219d0ebfe075b52fd39de49860975247a7 /usr.sbin/pkg_add/OpenBSD
parent024f77906b97fce9a8373ec1379798c0bef2117b (diff)
make things so that $state->print always work, with or without progressmeter,
even before we set it up.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/UpdateSet.pm15
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
index 9b701a782ce..19b44016c46 100644
--- a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
+++ b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: UpdateSet.pm,v 1.17 2009/11/11 11:13:16 espie Exp $
+# $OpenBSD: UpdateSet.pm,v 1.18 2009/11/11 11:17:11 espie Exp $
#
# Copyright (c) 2007 Marc Espie <espie@openbsd.org>
#
@@ -75,6 +75,7 @@ sub init
{
my $self = shift;
$self->{l} = OpenBSD::Log->new;
+ $self->{progressmeter} = bless {}, "OpenBSD::StubProgress";
}
sub log
@@ -87,6 +88,12 @@ sub log
}
}
+sub print
+{
+ my $self = shift;
+ $self->progress->print(@_);
+}
+
sub system
{
my $self = shift;
@@ -106,8 +113,6 @@ sub setup_progressmeter
if (!$opt_x && !$self->{beverbose}) {
require OpenBSD::ProgressMeter;
$self->{progressmeter} = OpenBSD::ProgressMeter->new;
- } else {
- $self->{progressmeter} = bless {}, "OpenBSD::StubProgress";
}
}
@@ -127,7 +132,7 @@ sub choose_location
{
my ($state, $name, $list) = @_;
if (@$list == 0) {
- $state->progress->print("Can't find $name\n");
+ $state->print("Can't find $name\n");
return undef;
} elsif (@$list == 1) {
return $list->[0];
@@ -142,7 +147,7 @@ sub choose_location
my $result = OpenBSD::Interactive::ask_list("Ambiguous: choose package for $name", 1, sort keys %h);
return $h{$result};
} else {
- $state->progress->print("Ambiguous: $name could be ",
+ $state->print("Ambiguous: $name could be ",
join(' ', keys %h), "\n");
return undef;
}