Skip to content

Commit 9df4f30

Browse files
axel3rdmichael-o
authored andcommitted
Quote Java binary when contain space (on Windows)
This closes #16
1 parent c9d5727 commit 9df4f30

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,13 @@ public void testOnlyQuotedPath()
461461
throw new IOException( java.getAbsolutePath() + " doesn't exist" );
462462
}
463463

464-
createAndCallScript( dir, java.getAbsolutePath() + " -version" );
464+
String javaBinStr = java.getAbsolutePath();
465+
if ( Os.isFamily( Os.FAMILY_WINDOWS ) && javaBinStr.contains( " " ) )
466+
{
467+
javaBinStr = "\"" + javaBinStr + "\"";
468+
}
469+
470+
createAndCallScript( dir, javaBinStr + " -version" );
465471
}
466472

467473
public void testDollarSignInArgumentPath()
@@ -515,7 +521,7 @@ public void testTimeOutException() throws Exception
515521
{
516522
throw new IOException( java.getAbsolutePath() + " doesn't exist" );
517523
}
518-
524+
519525
Commandline cli = new Commandline();
520526
cli.setExecutable( java.getAbsolutePath() );
521527
cli.createArg().setLine( "-version" );
@@ -529,9 +535,9 @@ public void testTimeOutException() throws Exception
529535
{
530536
// it works
531537
}
532-
538+
533539
}
534-
540+
535541
/**
536542
* Make the file executable for Unix box.
537543
*

0 commit comments

Comments
 (0)