]> git.proxmox.com Git - pve-common.git/commitdiff
cli: filter out aliases when trying to expand command
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 13 Jun 2018 07:37:50 +0000 (09:37 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 14 Jun 2018 06:58:54 +0000 (08:58 +0200)
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@proxmox.com>
src/PVE/CLIHandler.pm

index 9bbc15627bff5a385d4198fc80b77e643b3b81d4..49a459ba26299877c3d2abcd53feb0085c50eb65 100644 (file)
@@ -54,7 +54,9 @@ my $expand_command_name = sub {
 
     return $cmd if exists $def->{$cmd}; # command is already complete
 
 
     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;
     return $expanded[0] if scalar(@expanded) == 1; # enforce exact match
 
     return undef;