elharo commented on code in PR #434:
URL:
https://github.com/apache/maven-shared-utils/pull/434#discussion_r3989162534
##########
src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java:
##########
@@ -143,6 +147,51 @@ public void
executeCommandLineWithLargeStdoutCompletesWithoutFailure() throws Ex
}
}
+ @TempDir
+ File tempDir;
+
+ @Test
+ public void executeCommandLineOnWindowsPassesCmdSpecialCharactersThrough()
throws Exception {
+ if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
+ return;
+ }
+
+ // MSHARED-765: unquoted, cmd.exe runs "echo a" and then tries to run
"b"
+ Commandline cl = new Commandline();
+ cl.setExecutable("echo");
+ cl.createArg().setValue("a&b");
+
+ CommandLineUtils.StringStreamConsumer stdout = new
CommandLineUtils.StringStreamConsumer();
+ CommandLineUtils.StringStreamConsumer stderr = new
CommandLineUtils.StringStreamConsumer();
+ int exitCode = CommandLineUtils.executeCommandLine(cl, stdout, stderr);
+
+ assertEquals(0, exitCode, stderr.getOutput());
+ assertEquals("\"a&b\"" + System.lineSeparator(), stdout.getOutput());
+ }
+
+ @Test
+ public void
executeCommandLineOnWindowsRunsExecutableFromPathWithParentheses() throws
Exception {
+ if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
+ return;
+ }
+
+ // MSHARED-832: C:\work\lol(1)\maven\bin\mvn.cmd
+ File dir = new File(tempDir, "lol(1)");
+ assertTrue(dir.mkdirs());
+ File script = new File(dir, "x.cmd");
+ Files.write(script.toPath(), "@echo
ok".getBytes(StandardCharsets.US_ASCII));
+
+ Commandline cl = new Commandline();
Review Comment:
cl --> commandLine
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]