@@ -401,7 +401,7 @@ public String apply() {
401401 debugMode = true ;
402402 debug ("Enabled debug mode\n " + debugState ("" ));
403403 }
404-
404+ continue ;
405405 } else if (parseOptions && quickOptionMap .containsKey (param )) {
406406 // Found an option
407407 final OptionHandle optionHandle = quickOptionMap .get (param );
@@ -450,6 +450,7 @@ public String apply() {
450450 throw new CmdlineParserException (msg .notr (), e , msg .tr ());
451451 }
452452 }
453+ continue ;
453454 } else if (parseOptions && quickCommandMap .containsKey (param )) {
454455 // Found a command
455456 final CommandHandle commandHandle = quickCommandMap .get (param );
@@ -461,19 +462,29 @@ public String apply() {
461462 Arrays .copyOfRange (rest , index + 1 , rest .length ));
462463 // Stop parsing
463464 break ;
464- } else if (parseOptions
465+ }
466+
467+ if (parseOptions
465468 && aggregateShortOptionsWithPrefix .isDefined ()
466469 && param .startsWith (aggregatePrefix )
467470 && param .length () > aggregatePrefixSize + 1 ) {
471+
468472 // Found an aggregated short option
473+
474+ // if true, the match is not a valid option aggrgation and
475+ // should later be handled as normal parameter
476+ boolean failed = false ;
477+
469478 final char [] singleOptions = param .substring (aggregatePrefixSize ).toCharArray ();
470479 // rewrite the cmdline
471480 final List <String > rewritten = new LinkedList <String >();
472481 int procCount = 1 ;
473482 for (final char c : singleOptions ) {
474483 final OptionHandle oh = shortOptionMap .get (String .valueOf (c ));
475484 if (oh == null ) {
476- // FIXME: unsupported aggregation found
485+ // unsupported aggregation found
486+ failed = true ;
487+ break ;
477488 }
478489 if (rest .length < procCount + oh .getArgsCount ()) {
479490 // FIXME: missing args detected
@@ -495,15 +506,18 @@ public String apply() {
495506 ++procCount ;
496507 }
497508 }
498- // re-interate parsing with the modified command line
499- // (backtracking)
500- final String [] newRest = Arrays .copyOfRange (rest , procCount , rest .length );
501- rewritten .addAll (Arrays .asList (newRest ));
502- rest = rewritten .toArray (new String [0 ]);
503- index = -1 ;
504- continue ;
509+ if (!failed ) {
510+ // re-interate parsing with the modified command line
511+ // (backtracking)
512+ final String [] newRest = Arrays .copyOfRange (rest , procCount , rest .length );
513+ rewritten .addAll (Arrays .asList (newRest ));
514+ rest = rewritten .toArray (new String [0 ]);
515+ index = -1 ;
516+ continue ;
517+ }
518+ }
505519
506- } else if (parameter == null && defaultCommandName != null
520+ if (parameter == null && defaultCommandName != null
507521 && quickCommandMap .containsKey (defaultCommandName )) {
508522 // Assume a default command inserted here
509523 debug ("Unsupported option '" + param + "' found, assuming default command: " + defaultCommandName );
0 commit comments