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

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Jun 14 09:03:59 CEST 2018


applied both patches and added an exists() around the $_[0]->{alias}
part in $is_alias.

On Wed, Jun 13, 2018 at 09:37:50AM +0200, Thomas Lamprecht wrote:
> 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