Skip to content

Commit

Permalink
CommandBuilder.java: Don't quote the last argument when passing Wind…
Browse files Browse the repository at this point in the history
…ows command to CMD.EXE.

    Fix bazelbuild/bazel#2040 (comment)

    RELNOTES: None
    PiperOrigin-RevId: 165562681
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent b76bcd0 commit 06de905
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,10 @@ private String[] transformArgvForWindows() {
// args can contain whitespace, so figure out the first word
String argv0 = modifiedArgv.get(0);
String command = ARGV_SPLITTER.split(argv0).iterator().next();

// Automatically enable CMD.EXE use if we are executing something else besides "*.exe" file.
// When use CMD.EXE to invoke a bat/cmd file, the file path must have '\' instead of '/'
if (!command.toLowerCase().endsWith(".exe")) {
useShell = true;
modifiedArgv.set(0, argv0.replace('/', '\\'));
}
} else {
// This is degenerate "/bin/sh -c" case. We ensure that Windows behavior is identical
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void assertFailure(CommandBuilder builder, String expected) {
builder.build();
fail("Expected exception");
} catch (Exception e) {
assertThat(e).hasMessageThat().isEqualTo(expected);
assertThat(e).hasMessage(expected);
}
}

Expand Down

0 comments on commit 06de905

Please sign in to comment.