summaryrefslogtreecommitdiff
path: root/Debian/Debhelper/Dh_Lib.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-02-21 21:59:31 -0500
committerJoey Hess <joey@gnu.kitenet.net>2009-02-21 21:59:31 -0500
commit579d1345f2e2e3082304ab0460547f9683cfdb3e (patch)
tree8f4a6438fa140dc12379b0a457d066af7878117f /Debian/Debhelper/Dh_Lib.pm
parent09090c86ea099008990bc5a9a14e1ac35bb1e584 (diff)
Improve error messages when child commands fail.
Diffstat (limited to 'Debian/Debhelper/Dh_Lib.pm')
-rw-r--r--Debian/Debhelper/Dh_Lib.pm19
1 files changed, 15 insertions, 4 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index f0aa71d..a11c36a 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -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