aboutsummaryrefslogtreecommitdiffhomepage
path: root/devel
diff options
context:
space:
mode:
authorGravatar W. Trevor King <wking@tremily.us>2014-07-06 13:40:19 -0700
committerGravatar David Bremner <david@tethera.net>2014-07-16 06:31:23 -0300
commit4697e86a523fbbe43bf7ef38169f526adcbd710c (patch)
tree1c91e3119a88040fcff1e0c9166f183446734ce0 /devel
parentf47eeac0b0186c3559eb559c4f0bee0e1fac1961 (diff)
nmbug: Add a git_with_status helper function
Sometimes we want to catch Git errors and handle them, instead of dying with an error message. This lower-level version of git() allows us to get the error status when we want it.
Diffstat (limited to 'devel')
-rwxr-xr-xdevel/nmbug/nmbug13
1 files changed, 10 insertions, 3 deletions
diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug
index b18ded7b..4a797226 100755
--- a/devel/nmbug/nmbug
+++ b/devel/nmbug/nmbug
@@ -63,13 +63,20 @@ sub git_pipe {
spawn ($envref, defined $ioref ? $ioref : (), defined $dir ? $dir : (), @_);
}
-sub git {
+sub git_with_status {
my $fh = git_pipe (@_);
my $str = join ('', <$fh>);
- unless (close $fh) {
+ close $fh;
+ my $status = $?;
+ chomp($str);
+ return ($str, $status);
+}
+
+sub git {
+ my ($str, $status) = git_with_status (@_);
+ if ($status) {
die "'git @_' exited with nonzero value\n";
}
- chomp($str);
return $str;
}