From: Thomas Lamprecht Date: Tue, 11 Apr 2023 13:08:29 +0000 (+0200) Subject: cli handler: fix "return" statement followed by "sort" critic X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=646a36efce863c04b63f36dbdddefdbf146bf611 cli handler: fix "return" statement followed by "sort" critic As that's undefined behavior if the containing sub is called in scalar context. https://metacpan.org/pod/Perl::Critic::Policy::Subroutines::ProhibitReturnSort Signed-off-by: Thomas Lamprecht --- diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm index 64c3f95..64de8f7 100644 --- a/src/PVE/CLIHandler.pm +++ b/src/PVE/CLIHandler.pm @@ -350,7 +350,7 @@ sub print_usage_short { print {$fd} generate_usage_str('short', $cmd, ' ' x 7, $cmd ? '' : "\n", sub { my ($h) = @_; - return sort { + my @sorted_commands = sort { if (ref($h->{$a}) eq 'ARRAY' && ref($h->{$b}) eq 'ARRAY') { # $a and $b are both real commands order them by their class return $h->{$a}->[0] cmp $h->{$b}->[0] || $a cmp $b; @@ -362,6 +362,7 @@ sub print_usage_short { return $a cmp $b; } } keys %$h; + return @sorted_commands; }); }