File tree Expand file tree Collapse file tree
main/java/org/apache/commons/cli
test/java/org/apache/commons/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -580,7 +580,7 @@ private boolean isArgument(final String token) {
580580 * Tests if the specified token is a Java-like property (-Dkey=value).
581581 */
582582 private boolean isJavaProperty (final String token ) {
583- final String opt = token .substring (0 , 1 );
583+ final String opt = token .isEmpty () ? null : token . substring (0 , 1 );
584584 final Option option = options .getOption (opt );
585585
586586 return option != null && (option .getArgs () >= 2 || option .getArgs () == Option .UNLIMITED_VALUES );
Original file line number Diff line number Diff line change @@ -1020,5 +1020,12 @@ public void testWithRequiredOption() throws Exception {
10201020 assertEquals ("Confirm arg of -b" , "file" , cl .getOptionValue ("b" ));
10211021 assertTrue ("Confirm NO of extra args" , cl .getArgList ().isEmpty ());
10221022 }
1023-
1023+
1024+ @ Test (expected = UnrecognizedOptionException .class )
1025+ public void testAmbiguousArgParsing () throws Exception {
1026+ final String [] args = {"-=-" };
1027+ final Options options = new Options ();
1028+
1029+ final CommandLine cl = parser .parse (options , args );
1030+ }
10241031}
You can’t perform that action at this time.
0 commit comments