]> git.proxmox.com Git - aab.git/blobdiff - PVE/AAB.pm
run_command: allow to opt-out dying on non-zero exit code
[aab.git] / PVE / AAB.pm
index ccac7f2e00ea50a90b8412feab5777031c567aee..befae5f35f4a7411b548fb2cf3227286b7416693 100644 (file)
@@ -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 {