]> git.donarmstrong.com Git - debhelper.git/commitdiff
Improve error messages when child commands fail.
authorJoey Hess <joey@gnu.kitenet.net>
Sun, 22 Feb 2009 02:59:31 +0000 (21:59 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Sun, 22 Feb 2009 02:59:31 +0000 (21:59 -0500)
Debian/Debhelper/Dh_Lib.pm
debian/changelog

index f0aa71df5c68270abf9da0969968e6d6e05c913b..a11c36a37ce7b5bfd8a900ccd307a516d6e78e07 100644 (file)
@@ -162,8 +162,7 @@ sub doit {
        verbose_print(escape_shell(@_));
 
        if (! $dh{NO_ACT}) {
-               my $ret=system(@_);
-               $ret == 0 || error("command returned error code $ret");
+               system(@_) == 0 || _error_exitcode($_[0]);
        }
 }
 
@@ -176,11 +175,23 @@ sub complex_doit {
        
        if (! $dh{NO_ACT}) {
                # The join makes system get a scalar so it forks off a shell.
-               system(join(" ",@_)) == 0
-                       || error("command returned error code");
+               system(join(" ", @_)) == 0 || _error_exitcode(join(" ", @_))
        }                       
 }
 
+sub _error_exitcode {
+       my $command=shift;
+       if ($? == -1) {
+               error("$command failed to to execute: $!");
+       }
+       elsif ($? & 127) {
+               error("$command died with signal ".($? & 127));
+        }
+       else {
+               error("$command returned exit code ".($? >> 8));
+       }
+}
+
 # Run a command that may have a huge number of arguments, like xargs does.
 # Pass in a reference to an array containing the arguments, and then other
 # parameters that are the command and any parameters that should be passed to
index 89403bd8960c71ec0173e3c47ea59da92e79bd86..4985542f7ca759d08759a8f2e1f427d3aa4419db 100644 (file)
@@ -14,6 +14,7 @@ debhelper (7.2.0) UNRELEASED; urgency=low
   * dh: Support debian/rules calling make with -B,
     which is useful to avoid issues with phony implicit
     rules (see bug #509756).
+  * Improve error messages when child commands fail.
 
  -- Joey Hess <joeyh@debian.org>  Thu, 25 Dec 2008 16:26:36 -0500