]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/CLIHandler.pm
cli: filter out aliases when trying to expand command
[pve-common.git] / 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
 
-    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;