]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/CLIHandler.pm
fix #2696: avoid 'undefined value' warning in 'pvesh help unknown'
[pve-common.git] / src / PVE / CLIHandler.pm
index 86c90fb10a03757318941ecbc173522f65cae281..9955d77e06395c85dd219dac7d9f322bc1824992 100644 (file)
@@ -8,6 +8,7 @@ use Scalar::Util qw(weaken);
 
 use PVE::SafeSyslog;
 use PVE::Exception qw(raise raise_param_exc);
+use PVE::JSONSchema;
 use PVE::RESTHandler;
 use PVE::PTY;
 use PVE::INotify;
@@ -234,8 +235,8 @@ sub generate_usage_str {
 
            }
        } else {
+           $abort->("unknown command '$cmd->[0]'") if !$def;
            my ($class, $name, $arg_param, $fixed_param, undef, $formatter_properties) = @$def;
-           $abort->("unknown command '$cmd'") if !$class;
 
            $str .= $indent;
            $str .= $class->usage_str($name, $prefix, $arg_param, $fixed_param, $format, $param_cb, $formatter_properties);
@@ -518,7 +519,7 @@ function _$exename() {
     cmd=\${words[1]}
     curr=\${words[cwords]}
     prev=\${words[cwords-1]}
-    compadd \$(COMP_CWORD="\$cwords" COMP_LINE="\$line" COMP_POINT="\$point" \\
+    compadd -- \$(COMP_CWORD="\$cwords" COMP_LINE="\$line" COMP_POINT="\$point" \\
        $exename bashcomplete "\$cmd" "\$curr" "\$prev")
 }
 __EOD__