Fix behavior on empty completion request

This commit is contained in:
Martchus 2017-04-05 22:56:01 +02:00
parent f86a8b3700
commit 71231c29da
1 changed files with 4 additions and 2 deletions

View File

@ -665,9 +665,11 @@ void ArgumentParser::readArgs(int argc, const char * const *argv)
// the first argument after "--bash-completion-for" is the index of the current word
try {
currentWordIndex = (--argc ? stringToNumber<unsigned int, string>(*(++argv)) : 0);
++argv, --argc;
} catch(const ConversionException &) {
currentWordIndex = static_cast<unsigned int>(argc - 1);
currentWordIndex = static_cast<unsigned int>(argc);
}
if(argc) {
++argv, --argc;
}
}