From 034835001d6bd86fd4375f1df6b1074f3ea5822d Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 2 Dec 2021 14:42:38 +0100 Subject: [PATCH] run_command: allow to opt-out dying on non-zero exit code Signed-off-by: Thomas Lamprecht --- PVE/AAB.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PVE/AAB.pm b/PVE/AAB.pm index ccac7f2..befae5f 100644 --- a/PVE/AAB.pm +++ b/PVE/AAB.pm @@ -367,7 +367,7 @@ sub ve_exec { } sub run_command { - my ($self, $cmd, $input, $getoutput) = @_; + my ($self, $cmd, $input, $getoutput, $noerr) = @_; my $reader = IO::File->new(); my $writer = IO::File->new(); @@ -428,9 +428,9 @@ sub run_command { waitpid ($pid, 0); my $ec = ($? >> 8); - die "command '$cmdstr' failed with exit code $ec\n" if $ec; + die "command '$cmdstr' failed with exit code $ec\n" if $ec && !$noerr; - return $res; + return wantarray ? ($res, $ec) : $res; } sub start_container {