From 97af1e481f7a267ac4399c5eec428238acc54ee6 Mon Sep 17 00:00:00 2001 From: Rene Kita Date: Fri, 14 Jan 2022 13:11:04 +0100 Subject: [PATCH] Do not swallow errors from GCC Without this patch posubst always exits with 0. This is a problem when chaining commands. --- posubst.in | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/posubst.in b/posubst.in index f542e0d..dfd043f 100644 --- a/posubst.in +++ b/posubst.in @@ -52,5 +52,22 @@ foreach my $src (@src) { } map {s/(.*\.c)$/.$1/} @ARGV; +my $err = 0; system @ARGV; +if ($? == -1) { + print "failed to execute: $!\n"; + $err = 125; +} +elsif ($? & 127) { + printf "child died with signal %d\n", ($? & 127); + $err = 125; +} +else { + $err = $? >> 8; + if ($err != 0) { + printf "child exited with value %d\n", $err; + } +} + unlink @tmp; +exit $err;