From a6a91af233681a42a3ef9db5eb6f1f5fa52ec22c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 1 Nov 2016 15:19:35 +0000 Subject: [PATCH] Bug 17532: Make koha-shell -c propagate the error code When you execute a command using koha-shell -c, you would like to get the error code of the command you executed. It seems that koha-shell does not do that. --- debian/scripts/koha-shell | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/debian/scripts/koha-shell b/debian/scripts/koha-shell index b8d92f5..942f024 100755 --- a/debian/scripts/koha-shell +++ b/debian/scripts/koha-shell @@ -53,14 +53,16 @@ push @su_args, . ( $opts{command} ? " -c '$opts{command}'" : '' ); print "Command: '".join("' '",@su_args)."'\n" if $opts{verbose}; -system("@su_args"); -if ( $? == -1 ) { - print STDERR "failed to execute: $!\n"; +my $r = system("@su_args"); +if ( $r == -1 ) { + die "failed to execute: $!\n"; } -elsif ( $? & 127 ) { - printf STDERR "child died with signal %d, %s coredump\n", - ( $? & 127 ), ( $? & 128 ) ? 'with' : 'without'; +elsif ( $r & 127 ) { + die "child died with signal %d, %s coredump\n", + ( $r & 127 ), ( $r & 128 ) ? 'with' : 'without'; } +exit(0) if $r == 0; +exit(1); sub show_help { my ( $err, $msg ) = @_; -- 2.1.4