chiark / gitweb /
Dgit.pm: failedcmd_report_cmd: Break out of failedcmd
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 19 Oct 2016 21:54:47 +0000 (22:54 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 23 Oct 2016 12:31:30 +0000 (13:31 +0100)
No functional change.

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

index 5c43f02..6854a7c 100644 (file)
@@ -41,7 +41,7 @@ BEGIN {
                       stat_exists link_ltarget
                      hashfile
                       fail ensuredir executable_on_path
-                      waitstatusmsg failedcmd
+                      waitstatusmsg 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
@@ -217,6 +217,12 @@ sub waitstatusmsg () {
     }
 }
 
+sub failedcmd_report_cmd {
+    my $intro = shift @_;
+    $intro //= "failed command";
+    { local ($!); printcmd \*STDERR, _us().": $intro:", @_ or die $!; };
+}
+
 sub failedcmd {
     # Expects $!,$? as set by close - see below.
     # To use with system(), set $?=-1 first.
@@ -229,7 +235,7 @@ sub failedcmd {
     #   success              trashed     $?==0       system
     #   program failed       trashed     $? >0       system
     #   syscall failure      $! >0       unchanged   system
-    { local ($!); printcmd \*STDERR, _us().": failed command:", @_ or die $!; };
+    failedcmd_report_cmd undef, @_;
     if ($? < 0) {
        fail "failed to fork/exec: $!";
     } elsif ($?) {