summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2014-05-20 05:43:56 +0000
committerMarc Espie <espie@cvs.openbsd.org>2014-05-20 05:43:56 +0000
commit575ba4b9a4002d8218bcf2a9be19c60a9b9d2399 (patch)
treeebc40e31cb9458be0f0223db2d7e6230a823a5f9
parent597da3199199b14e2722a1ada9fccb3737814d7f (diff)
fix bogus extension: $code and $code2 belong in _system, so that
both system and verbose_system will work properly.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/State.pm38
1 files changed, 16 insertions, 22 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/State.pm b/usr.sbin/pkg_add/OpenBSD/State.pm
index e51d8b8753b..cbca91a79d8 100644
--- a/usr.sbin/pkg_add/OpenBSD/State.pm
+++ b/usr.sbin/pkg_add/OpenBSD/State.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: State.pm,v 1.27 2014/03/18 18:53:29 espie Exp $
+# $OpenBSD: State.pm,v 1.28 2014/05/20 05:43:55 espie Exp $
#
# Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org>
#
@@ -401,13 +401,24 @@ sub child_error
sub _system
{
- my ($self, $todo, $todo2, @r) = @_;
+ my $self = shift;
my $r = fork;
+ my ($todo, $todo2);
+ if (ref $_[0] eq 'CODE') {
+ $todo = shift;
+ } else {
+ $todo = sub {};
+ }
+ if (ref $_[0] eq 'CODE') {
+ $todo2 = shift;
+ } else {
+ $todo2 = sub {};
+ }
if (!defined $r) {
return 1;
} elsif ($r == 0) {
&$todo;
- exec {$r[0]} @r or return 1;
+ exec {$_[0]} @_ or return 1;
} else {
&$todo2;
waitpid($r, 0);
@@ -418,18 +429,7 @@ sub _system
sub system
{
my $self = shift;
- my ($todo, $todo2);
- if (ref $_[0] eq 'CODE') {
- $todo = shift;
- } else {
- $todo = sub {};
- }
- if (ref $_[0] eq 'CODE') {
- $todo2 = shift;
- } else {
- $todo2 = sub {};
- }
- my $r = $self->_system($todo, $todo2, @_);
+ my $r = $self->_system(@_);
if ($r != 0) {
$self->say("system(#1) failed: #2",
join(", ", @_), $self->child_error);
@@ -440,15 +440,9 @@ sub system
sub verbose_system
{
my $self = shift;
- my $todo;
- if (ref $_[0] eq 'CODE') {
- $todo = shift;
- } else {
- $todo = sub {};
- }
$self->print("Running #1", join(' ', @_));
- my $r = $self->_system($todo, @_);
+ my $r = $self->_system(@_);
if ($r != 0) {
$self->say("... failed: #1", $self->child_error);
} else {