From: Thomas Lamprecht Date: Wed, 13 Jun 2018 07:37:50 +0000 (+0200) Subject: cli: filter out aliases when trying to expand command X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=0b7968069490682defe88b5ad03ba349939dc617 cli: filter out aliases when trying to expand command we do not complete them in bash copletion either and their just there for backward compatibillity, so filter them out. Signed-off-by: Thomas Lamprecht --- diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm index 9bbc156..49a459b 100644 --- a/src/PVE/CLIHandler.pm +++ b/src/PVE/CLIHandler.pm @@ -54,7 +54,9 @@ my $expand_command_name = sub { return $cmd if exists $def->{$cmd}; # command is already complete - my @expanded = grep { /^\Q$cmd\E/ } keys %$def; + my $is_alias = sub { ref($_[0]) eq 'HASH' && $_[0]->{alias} }; + my @expanded = grep { /^\Q$cmd\E/ && !$is_alias->($def->{$_}) } keys %$def; + return $expanded[0] if scalar(@expanded) == 1; # enforce exact match return undef;