If $noprint is set, the output of the command won't be printed to stdout
of the parent process.

Fully backwards-compatible again, only takes effect if the new argument
is actually specified.

Signed-off-by: Christoph Heiss <c.he...@proxmox.com>
---
Changes since v1:
  * added parameter documentation

 Proxmox/Sys/Command.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Proxmox/Sys/Command.pm b/Proxmox/Sys/Command.pm
index 36e99c1..d145483 100644
--- a/Proxmox/Sys/Command.pm
+++ b/Proxmox/Sys/Command.pm
@@ -85,8 +85,9 @@ sub syscmd {
 #           to exit early and ignore the rest of the process output.
 # * $input - Stdin contents for the spawned subprocess
 # * $noout - Whether to append any process output to the return value
+# * $noprint - Whether to print any process output to the parents stdout
 sub run_command {
-    my ($cmd, $func, $input, $noout) = @_;
+    my ($cmd, $func, $input, $noout, $noprint) = @_;

     my $cmdstr;
     if (!ref($cmd)) {
@@ -178,7 +179,7 @@ sub run_command {
            } elsif ($h eq $error) {
                $ostream .= $buf if !($noout || $func);
            }
-           print $buf;
+           print $buf if !$noprint;
            STDOUT->flush();
            log_info($buf);
        }
--
2.43.0



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to