From: Vincent Pit Date: Wed, 24 Feb 2010 17:22:13 +0000 (+0100) Subject: Yet less namespace pollution X-Git-Tag: v0.07~7 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=517c579bda9717613f7faa9ffe41ef1648199e9b;p=perl%2Fmodules%2Frgit.git Yet less namespace pollution --- diff --git a/lib/App/Rgit/Repository.pm b/lib/App/Rgit/Repository.pm index a921576..df44edc 100644 --- a/lib/App/Rgit/Repository.pm +++ b/lib/App/Rgit/Repository.pm @@ -5,13 +5,19 @@ use warnings; use Cwd (); # cwd, abs_path use File::Spec (); # canonpath, catdir, splitdir, abs2rel -use POSIX qw/WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG SIGINT SIGQUIT/; +use POSIX (); # WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG SIGINT SIGQUIT + +my ($WIFEXITED, $WEXITSTATUS, $WIFSIGNALED, $WTERMSIG); BEGIN { - no warnings 'redefine'; - *WIFEXITED = sub { 1 } unless eval { WIFEXITED(0); 1 }; - *WEXITSTATUS = sub { shift() >> 8 } unless eval { WEXITSTATUS(0); 1 }; - *WIFSIGNALED = sub { shift() & 127 } unless eval { WIFSIGNALED(0); 1 }; + $WIFEXITED = eval { POSIX::WIFEXITED(0); 1 } ? \&POSIX::WIFEXITED + : sub { 1 }; + $WEXITSTATUS = eval { POSIX::WEXITSTATUS(0); 1 } ? \&POSIX::WEXITSTATUS + : sub { shift() >> 8 }; + $WIFSIGNALED = eval { POSIX::WIFSIGNALED(0); 1 } ? \&POSIX::WIFSIGNALED + : sub { shift() & 127 }; + $WTERMSIG = eval { POSIX::WTERMSIG(0); 1 } ? \&POSIX::WTERMSIG + : sub { shift() & 127 }; } =head1 NAME @@ -168,12 +174,12 @@ sub run { } my $ret; - $ret = WEXITSTATUS($?) if WIFEXITED($?); + $ret = $WEXITSTATUS->($?) if $WIFEXITED->($?); my $sig; - if (WIFSIGNALED($?)) { - $sig = WTERMSIG($?); + if ($WIFSIGNALED->($?)) { + $sig = $WTERMSIG->($?); $conf->warn("git died with signal $sig\n"); - if ($sig == SIGINT || $sig == SIGQUIT) { + if ($sig == POSIX::SIGINT || $sig == POSIX::SIGQUIT) { $conf->err("Aborting\n"); exit $sig; } diff --git a/t/lib/App/Rgit/TestUtils.pm b/t/lib/App/Rgit/TestUtils.pm index f702b25..321f964 100644 --- a/t/lib/App/Rgit/TestUtils.pm +++ b/t/lib/App/Rgit/TestUtils.pm @@ -13,6 +13,7 @@ BEGIN { *WIFEXITED = sub { 1 } unless eval { WIFEXITED(0); 1 }; *WEXITSTATUS = sub { shift() >> 8 } unless eval { WEXITSTATUS(0); 1 }; *WIFSIGNALED = sub { shift() & 127 } unless eval { WIFSIGNALED(0); 1 }; + *WTERMSIG = sub { shift() & 127 } unless eval { WTERMSIG(0); 1 }; } use base qw/Exporter/;