]> git.proxmox.com Git - pve-cluster.git/commitdiff
refactor run_silent_cmd
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 14 Dec 2018 10:07:42 +0000 (11:07 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 14 Dec 2018 10:07:42 +0000 (11:07 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/PVE/Cluster.pm

index 93c3f01eff2e6529017d7b36ba3bf565bbd40c74..f4dd1a3a1877254d015f9513cf4c1c3d372d5977 100644 (file)
@@ -93,20 +93,11 @@ sub run_silent_cmd {
     my ($cmd) = @_;
 
     my $outbuf = '';
     my ($cmd) = @_;
 
     my $outbuf = '';
+    my $record = sub { $outbuf .= shift . "\n"; };
 
 
-    my $record_output = sub {
-       $outbuf .= shift;
-       $outbuf .= "\n";
-    };
-
-    eval {
-       PVE::Tools::run_command($cmd, outfunc => $record_output,
-                               errfunc => $record_output);
-    };
+    eval { run_command($cmd, outfunc => $record, errfunc => $record) };
 
 
-    my $err = $@;
-
-    if ($err) {
+    if (my $err = $@) {
        print STDERR $outbuf;
        die $err;
     }
        print STDERR $outbuf;
        die $err;
     }