From: Thomas Lamprecht Date: Fri, 14 Dec 2018 10:07:42 +0000 (+0100) Subject: refactor run_silent_cmd X-Git-Url: https://git.proxmox.com/?p=pve-cluster.git;a=commitdiff_plain;h=9cede62e7e25a507d9b9c74749b02aafc3644af8 refactor run_silent_cmd Signed-off-by: Thomas Lamprecht --- diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm index 93c3f01..f4dd1a3 100644 --- a/data/PVE/Cluster.pm +++ b/data/PVE/Cluster.pm @@ -93,20 +93,11 @@ sub run_silent_cmd { 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; }