Don't crash shell in completions if an option has been set twice

This commit is contained in:
Eric Bottard
2014-02-26 14:35:46 +01:00
parent e5adb8bc06
commit 74a0c49699

View File

@@ -577,7 +577,15 @@ public class SimpleParser implements Parser {
Assert.notNull(cmd, "CliCommand unavailable for '" + methodTarget.getMethod().toGenericString() + "'");
// Make a reasonable attempt at parsing the remainingBuffer
Tokenizer tokenizer = new Tokenizer(methodTarget.getRemainingBuffer(), true);
Tokenizer tokenizer = null;
try {
tokenizer = new Tokenizer(methodTarget.getRemainingBuffer(), true);
}
catch (IllegalArgumentException e) {
// Make sure we don't crash the mail shell loop just
// because the user specified some option twice
return -1;
}
Map<String, String> options = tokenizer.getTokens();
// Lookup arguments for this target