[pve-devel] [PATCH common 1/2] cli: filter out aliases when trying to expand command

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jun 13 09:37:50 CEST 2018


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 <t.lamprecht at proxmox.com>
---
 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.17.1





More information about the pve-devel mailing list