Fix command line parser for "icinga2 --version"

fixes #12632
This commit is contained in:
Gunnar Beutner 2016-09-04 17:01:46 +02:00
parent 5960753015
commit a2e70955e1
1 changed files with 5 additions and 2 deletions

View File

@ -171,6 +171,7 @@ bool CLICommand::ParseCommand(int argc, char **argv, po::options_description& vi
std::vector<String> best_match;
int arg_end = 0;
bool tried_command = false;
for (const CLIKeyValue& kv : GetRegistry()) {
const std::vector<String>& vname = kv.first;
@ -178,11 +179,13 @@ bool CLICommand::ParseCommand(int argc, char **argv, po::options_description& vi
std::vector<String>::size_type i;
int k;
for (i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
if (strcmp(argv[k], "--no-stack-rlimit") == 0 || strcmp(argv[k], "--autocomplete") == 0 || strcmp(argv[k], "--scm") == 0) {
if (strncmp(argv[k], "--", 2) == 0) {
i--;
continue;
}
tried_command = true;
if (vname[i] != argv[k])
break;
@ -207,7 +210,7 @@ found_command:
visibleDesc.add(vdesc);
}
if (autocomplete || !command)
if (autocomplete || (tried_command && !command))
return true;
po::options_description adesc;