3824: Show stdout/stderr if shell cmd fails in install script.
authorTom Clegg <tom@curoverse.com>
Wed, 22 Oct 2014 14:43:38 +0000 (10:43 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 22 Oct 2014 14:43:38 +0000 (10:43 -0400)
sdk/cli/bin/crunch-job

index 369bc3e1ae6f021fbd809ecc7fa82c4da2a77ccc..9bad7ae54740c0ac368e9b75cf2c6781dc28afcc 100755 (executable)
@@ -1718,6 +1718,7 @@ if (readlink ("$destdir.commit") eq $commit && -d $destdir) {
 }
 
 unlink "$destdir.commit";
+open STDERR_ORIG, ">&STDERR";
 open STDOUT, ">", "$destdir.log";
 open STDERR, ">&STDOUT";
 
@@ -1772,8 +1773,12 @@ sub shell_or_die
   if ($ENV{"DEBUG"}) {
     print STDERR "@_\n";
   }
-  system (@_) == 0
-      or die "@_ failed: $! exit 0x".sprintf("%x",$?);
+  if (system (@_) != 0) {
+    my $exitstatus = sprintf("exit %d signal %d", $? >> 8, $? & 0x7f);
+    open STDERR, ">&STDERR_ORIG";
+    system ("cat $destdir.log >&2");
+    die "@_ failed ($!): $exitstatus";
+  }
 }
 
 __DATA__