From 0b7968069490682defe88b5ad03ba349939dc617 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 13 Jun 2018 09:37:50 +0200 Subject: [PATCH] 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 --- src/PVE/CLIHandler.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- 2.39.2