aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xxmpt38
1 files changed, 21 insertions, 17 deletions
diff --git a/xmpt b/xmpt
index 3d7cb3f..2546092 100755
--- a/xmpt
+++ b/xmpt
@@ -32,24 +32,28 @@ usage(0) if $help;
$| = 1;
-local %evalpkg::env = read_env($envpath);
-my @plans = load_plans($testplanpath, $templatepath);
-
-# Ignore SIGPIPE at the top level, since it only matters when reading
-# or writing to the subprocess.
-local $SIG{PIPE} = sub {};
-
-my ($inh, $outh) = (\*STDIN, \*STDOUT);
-my $pid;
-if (@ARGV) {
- $inh = $outh = undef;
- $pid = open2($inh, $outh, join(' ', @ARGV));
-}
-binmode($inh, ':utf8');
-binmode($outh, ':utf8');
+eval {
+ local %evalpkg::env = read_env($envpath);
+ my @plans = load_plans($testplanpath, $templatepath);
+
+ # Ignore SIGPIPE at the top level, since it only matters when
+ # reading or writing to the subprocess.
+ local $SIG{PIPE} = sub {};
+
+ my ($inh, $outh) = (\*STDIN, \*STDOUT);
+ my $pid;
+ if (@ARGV) {
+ $inh = $outh = undef;
+ $pid = open2($inh, $outh, join(' ', @ARGV));
+ }
+ binmode($inh, ':utf8');
+ binmode($outh, ':utf8');
+
+ eval_in($inh, $outh, @plans);
+ waitpid($pid, 0) if $pid;
-eval_in($inh, $outh, @plans);
-waitpid($pid, 0) if $pid;
+ 1;
+} or error($@) and exit 3;
# TODO: swap over to Pod::Usage.
sub usage {