]> git.vpit.fr Git - perl/modules/rgit.git/commitdiff
Yet less namespace pollution
authorVincent Pit <vince@profvince.com>
Wed, 24 Feb 2010 17:22:13 +0000 (18:22 +0100)
committerVincent Pit <vince@profvince.com>
Wed, 24 Feb 2010 17:22:13 +0000 (18:22 +0100)
lib/App/Rgit/Repository.pm
t/lib/App/Rgit/TestUtils.pm

index a9215764fe68702825c5fa4e50f3013c4f49f6fa..df44edc754306d22f89605391dd73ec3fc614366 100644 (file)
@@ -5,13 +5,19 @@ use warnings;
 
 use Cwd        (); # cwd, abs_path
 use File::Spec (); # canonpath, catdir, splitdir, abs2rel
 
 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 {
 
 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
 }
 
 =head1 NAME
@@ -168,12 +174,12 @@ sub run {
  }
 
  my $ret;
  }
 
  my $ret;
- $ret = WEXITSTATUS($?) if WIFEXITED($?);
+ $ret = $WEXITSTATUS->($?) if $WIFEXITED->($?);
  my $sig;
  my $sig;
- if (WIFSIGNALED($?)) {
-  $sig = WTERMSIG($?);
+ if ($WIFSIGNALED->($?)) {
+  $sig = $WTERMSIG->($?);
   $conf->warn("git died with signal $sig\n");
   $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;
   }
    $conf->err("Aborting\n");
    exit $sig;
   }
index f702b25f57559b9eb43f60b7ee4cf5bc5da3a692..321f96474b6972f69f65ec0b490a6931dabd95d1 100644 (file)
@@ -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 };
  *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/;
 }
 
 use base qw/Exporter/;