fix bash completion for simple command classes like 'list'.
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 12 Jun 2018 06:07:50 +0000 (08:07 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 12 Jun 2018 09:17:45 +0000 (11:17 +0200)
PVE/CLIHandler.pm
pveclient

index 904e54e..801f530 100644 (file)
@@ -369,7 +369,6 @@ my $print_bash_completion = sub {
     };
 
     # positional arguments
-    $pos++ if $simple_cmd;
     if ($pos < scalar(@$arg_param)) {
        my $pname = $arg_param->[$pos];
        &$print_parameter_completion($pname);
index 4a0ae50..52f40a7 100755 (executable)
--- a/pveclient
+++ b/pveclient
@@ -69,10 +69,16 @@ if (my $method = $method_map->{$cmd}) {
     if ($ENV{COMP_LINE} =~ m/^(.*pveclient\s+($cmdlist)\s+)(.*)$/) {
        my $cmd = $2;
        my $class = $cli_class_handlers->{$cmd} || die "internal error";
-       $ENV{COMP_LINE} = "pveclient $3";
-       $ENV{COMP_POINT} = length($ENV{COMP_LINE});
-       @ARGV = ('bashcomplete', 'pveclient', $ARGV[1], $ARGV[2]);
 
+       if ($cmd eq 'list') { # simple commands
+           $ENV{COMP_LINE} = "pveclient $3";
+           $ENV{COMP_POINT} = length($ENV{COMP_LINE});
+           @ARGV = ('bashcomplete', 'pveclient', $ARGV[1], $ARGV[2]);
+       } else {
+           $ENV{COMP_LINE} = "pveclient $3";
+           $ENV{COMP_POINT} = length($ENV{COMP_LINE});
+           @ARGV = ('bashcomplete', 'pveclient', $ARGV[1], $ARGV[2]);
+       }
        $class->run_cli_handler();
 
     } else {