diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-10-23 09:43:17 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-10-23 09:43:17 +0000 |
commit | 5c68828fda69e5768cdbf352e9523e4201e7d102 (patch) | |
tree | ab4f7848889725a3185b7e43762b30c1184bcd2e /usr.sbin/pkg_add | |
parent | e667ecb9db6a33aeb94a2d5c3184a00a3e25f4bb (diff) |
system() method that stores command normal output so that we can show
it at end of pkg install/deinstall...
use for @exec/INSTALL stuff.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Error.pm | 18 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 6 |
2 files changed, 20 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Error.pm b/usr.sbin/pkg_add/OpenBSD/Error.pm index 22449344d3c..49fb8d86025 100644 --- a/usr.sbin/pkg_add/OpenBSD/Error.pm +++ b/usr.sbin/pkg_add/OpenBSD/Error.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Error.pm,v 1.4 2004/10/23 09:27:48 espie Exp $ +# $OpenBSD: Error.pm,v 1.5 2004/10/23 09:43:16 espie Exp $ # # Copyright (c) 2004 Marc Espie <espie@openbsd.org> # @@ -113,4 +113,20 @@ sub delayed_output } } +sub system +{ + my $state = shift; + if (open(my $grab, "-|", @_)) { + local $_; + while (<$grab>) { + $state->print($_); + } + if (!close $grab) { + $state->print("system(", join(", ", @_), ") failed: $! $?\n"); + } + return $?; + } else { + $state->print("system(", join(", ", @_), ") was not run: $! $?\n"); + } +} 1; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 7d967711c95..b642f8d3cd9 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.58 2004/10/20 11:38:57 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.59 2004/10/23 09:43:16 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -939,7 +939,7 @@ sub run main::ensure_ldconfig($state); print $self->keyword(), " ", $self->{expanded}, "\n" if $state->{beverbose}; - System('/bin/sh', '-c', $self->{expanded}) unless $state->{not}; + $state->system('/bin/sh', '-c', $self->{expanded}) unless $state->{not}; } package OpenBSD::PackingElement::Exec; @@ -1135,7 +1135,7 @@ sub run print $self->beautify(), " script: $dir$name $pkgname ", join(' ', @args), "\n" if $state->{beverbose}; return if $not; chmod 0755, $dir.$name; - return if System($dir.$name, $pkgname, @args) == 0; + return if $state->system($dir.$name, $pkgname, @args) == 0; Fatal $self->beautify()." script borked"; } |