chiark / gitweb /
Dgit.pm: Break out failedcmd_waitstatus
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 24 Oct 2016 00:01:58 +0000 (01:01 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 24 Oct 2016 00:43:50 +0000 (01:43 +0100)
No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit.pm

index 6854a7c..57ae994 100644 (file)
@@ -41,7 +41,8 @@ BEGIN {
                       stat_exists link_ltarget
                      hashfile
                       fail ensuredir executable_on_path
-                      waitstatusmsg failedcmd_report_cmd failedcmd
+                      waitstatusmsg failedcmd_waitstatus
+                     failedcmd_report_cmd failedcmd
                       cmdoutput cmdoutput_errok
                       git_rev_parse git_get_ref git_for_each_ref
                       git_for_each_tag_referring is_fast_fwd
@@ -223,6 +224,16 @@ sub failedcmd_report_cmd {
     { local ($!); printcmd \*STDERR, _us().": $intro:", @_ or die $!; };
 }
 
+sub failedcmd_waitstatus {
+    if ($? < 0) {
+       return "failed to fork/exec: $!";
+    } elsif ($?) {
+       return "subprocess ".waitstatusmsg();
+    } else {
+       return "subprocess produced invalid output";
+    }
+}
+
 sub failedcmd {
     # Expects $!,$? as set by close - see below.
     # To use with system(), set $?=-1 first.
@@ -236,13 +247,7 @@ sub failedcmd {
     #   program failed       trashed     $? >0       system
     #   syscall failure      $! >0       unchanged   system
     failedcmd_report_cmd undef, @_;
-    if ($? < 0) {
-       fail "failed to fork/exec: $!";
-    } elsif ($?) {
-       fail "subprocess ".waitstatusmsg();
-    } else {
-       fail "subprocess produced invalid output";
-    }
+    fail failedcmd_waitstatus();
 }
 
 sub cmdoutput_errok {