]> Sergey Matveev's repositories - public-inbox.git/commitdiff
init: use Import::run_die instead of system()
authorEric Wong <e@yhbt.net>
Sat, 25 Jan 2020 04:44:59 +0000 (04:44 +0000)
committerEric Wong <e@yhbt.net>
Mon, 27 Jan 2020 02:59:09 +0000 (02:59 +0000)
We already load PublicInbox::Import via
PublicInbox::InboxWritable, so it's not an extra module
to load.  This can give us a slight speedup in tests.

script/public-inbox-init

index 34c93b47882c3b52623a4de583197cc3c90f57cd..6221871e1bde392e618660100b36489995222d22 100755 (executable)
@@ -16,6 +16,7 @@ use PublicInbox::Admin;
 PublicInbox::Admin::require_or_die('-base');
 use PublicInbox::Config;
 use PublicInbox::InboxWritable;
+use PublicInbox::Import;
 use File::Temp qw/tempfile/;
 use PublicInbox::Lock;
 use File::Basename qw/dirname/;
@@ -23,7 +24,6 @@ use File::Path qw/mkpath/;
 use Fcntl qw(:DEFAULT);
 use Cwd qw/abs_path/;
 
-sub x { system(@_) and die join(' ', @_). " failed: $?\n" }
 my $version = undef;
 my $indexlevel = undef;
 my $skip_epoch;
@@ -151,13 +151,13 @@ umask(0077) if defined $perm;
 
 foreach my $addr (@address) {
        next if $seen{lc($addr)};
-       x(@x, "--add", "$pfx.address", $addr);
+       PublicInbox::Import::run_die([@x, "--add", "$pfx.address", $addr]);
 }
-x(@x, "$pfx.url", $http_url);
-x(@x, "$pfx.inboxdir", $inboxdir);
+PublicInbox::Import::run_die([@x, "$pfx.url", $http_url]);
+PublicInbox::Import::run_die([@x, "$pfx.inboxdir", $inboxdir]);
 
 if (defined($indexlevel)) {
-       x(@x, "$pfx.indexlevel", $indexlevel);
+       PublicInbox::Import::run_die([@x, "$pfx.indexlevel", $indexlevel]);
 }
 
 # needed for git prior to v2.1.0