From: espie Date: Tue, 20 May 2014 05:43:55 +0000 (+0000) Subject: fix bogus extension: $code and $code2 belong in _system, so that X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4117ed1bb0cc25fe0a5301642865d5bcdd53b447;p=openbsd fix bogus extension: $code and $code2 belong in _system, so that both system and verbose_system will work properly. --- 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 # @@ -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 {