aboutsummaryrefslogtreecommitdiffhomepage
path: root/contrib
diff options
context:
space:
mode:
authorGravatar Tomi Ollila <tomi.ollila@iki.fi>2012-04-01 21:28:42 +0300
committerGravatar David Bremner <bremner@debian.org>2012-06-03 13:45:28 -0300
commita114ac8b77c683fafb350e3f3e07fdbbcf4edd3f (patch)
treea72e9605404e2cf429de917d811b04dadb03b722 /contrib
parent00a8581e4dcc5112d502729b1698d9c1598d3413 (diff)
nmbug: check whether every forked process exit with (non)zero value
If any of the forked process exits with nonzero value, terminate current operation -- nonzero exit value indicates failure and then there is no point continuing.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/nmbug37
1 files changed, 32 insertions, 5 deletions
diff --git a/contrib/nmbug b/contrib/nmbug
index bb0739f8..f003ef9e 100755
--- a/contrib/nmbug
+++ b/contrib/nmbug
@@ -60,6 +60,9 @@ sub git_pipe {
sub git {
my $fh = git_pipe (@_);
my $str = join ('', <$fh>);
+ unless (close $fh) {
+ die "'git @_' exited with nonzero value\n";
+ }
chomp($str);
return $str;
}
@@ -84,7 +87,7 @@ sub spawn {
foreach my $line (@{$ioref}) {
print $fh $line, "\n";
}
- exit 0;
+ exit ! close $fh;
} else {
if ($dir ne '|-') {
open STDIN, '<', '/dev/null' or die "reopening stdin: $!"
@@ -106,6 +109,9 @@ sub get_tags {
chomp ();
push @tags, $_ if (m/^$prefix/);
}
+ unless (close $fh) {
+ die "'notmuch search --output=tags *' exited with nonzero value\n";
+ }
return @tags;
}
@@ -173,6 +179,10 @@ sub update_index {
foreach my $pair (@{$status->{added}}) {
index_tags_for_msg ($git, $pair->{id}, 'A', $pair->{tag});
}
+ unless (close $git) {
+ die "'git update-index --index-info' exited with nonzero value\n";
+ }
+
}
@@ -211,8 +221,12 @@ sub index_tags {
my @tags = grep { s/^$TAGPREFIX//; } split (' ', $rest);
index_tags_for_msg ($git,$id, 'A', @tags);
}
-
- close $git;
+ unless (close $git) {
+ die "'git update-index --index-info' exited with nonzero value\n";
+ }
+ unless (close $fh) {
+ die "'notmuch dump -- $query' exited with nonzero value\n";
+ }
return $index;
}
@@ -395,6 +409,9 @@ sub compute_status {
} else {
push @deleted, $pair;
}
+ unless (close $fh) {
+ die "'notmuch search --output=files id:$id' exited with nonzero value\n";
+ }
}
@@ -414,7 +431,12 @@ sub diff_index {
qw/diff-index --cached/,
"--diff-filter=$filter", qw/--name-only HEAD/ );
- return unpack_diff_lines ($fh);
+ my @lines = unpack_diff_lines ($fh);
+ unless (close $fh) {
+ die "'git diff-index --cached --diff-filter=$filter --name-only HEAD' ",
+ "exited with nonzero value\n";
+ }
+ return @lines;
}
@@ -426,7 +448,12 @@ sub diff_refs {
my $fh= git_pipe ( 'diff', "--diff-filter=$filter", '--name-only',
$ref1, $ref2);
- return unpack_diff_lines ($fh);
+ my @lines = unpack_diff_lines ($fh);
+ unless (close $fh) {
+ die "'git diff --diff-filter=$filter --name-only $ref1 $ref2' ",
+ "exited with nonzero value\n";
+ }
+ return @lines;
}