From 4fd788115bdd3e4fa3861bcb4b9caab480543da5 Mon Sep 17 00:00:00 2001 From: Laszlo Csomor Date: Tue, 14 Nov 2017 06:39:43 -0800 Subject: Windows,Subcommands: argv quoting for empty args Quote empty args in the command argument vector otherwise the command's executable would not recognize them as arguments. Fixes https://github.com/bazelbuild/bazel/issues/3973 Change-Id: Iccfb59e75c748247c8df7d52fb8cf4227eae6fa7 PiperOrigin-RevId: 175672201 --- .../google/devtools/build/lib/windows/jni/WindowsProcesses.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/main') diff --git a/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsProcesses.java b/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsProcesses.java index bb13941bcb..65b262088a 100644 --- a/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsProcesses.java +++ b/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsProcesses.java @@ -216,6 +216,9 @@ public class WindowsProcesses { private static native int nativeGetpid(); + // TODO(laszlocsomor): Audit this method and fix bugs. This method implements Bash quoting + // semantics but Windows quote semantics are different. + // More info: http://daviddeley.com/autohotkey/parameters/parameters.htm public static String quoteCommandLine(List argv) { StringBuilder result = new StringBuilder(); for (int iArg = 0; iArg < argv.size(); iArg++) { @@ -223,6 +226,10 @@ public class WindowsProcesses { result.append(" "); } String arg = argv.get(iArg); + if (arg.isEmpty()) { + result.append("\"\""); + continue; + } boolean hasSpace = arg.contains(" "); if (!arg.contains("\"") && !arg.contains("\\") && !hasSpace) { // fast path. Just append the input string. -- cgit v1.2.3