Merge "Respect '' received from aquery"
diff --git a/bazel/aquery.go b/bazel/aquery.go
index 4d39e8f..95e52ae 100644
--- a/bazel/aquery.go
+++ b/bazel/aquery.go
@@ -453,8 +453,32 @@
 	return hashes, nil
 }
 
+// escapes the args received from aquery and creates a command string
+func commandString(actionEntry *analysis_v2_proto.Action) string {
+	switch actionEntry.Mnemonic {
+	case "GoCompilePkg":
+		argsEscaped := []string{}
+		for _, arg := range actionEntry.Arguments {
+			if arg == "" {
+				// If this is an empty string, add ''
+				// And not
+				// 1. (literal empty)
+				// 2. `''\'''\'''` (escaped version of '')
+				//
+				// If we had used (1), then this would appear as a whitespace when we strings.Join
+				argsEscaped = append(argsEscaped, "''")
+			} else {
+				argsEscaped = append(argsEscaped, proptools.ShellEscapeIncludingSpaces(arg))
+			}
+		}
+		return strings.Join(argsEscaped, " ")
+	default:
+		return strings.Join(proptools.ShellEscapeListIncludingSpaces(actionEntry.Arguments), " ")
+	}
+}
+
 func (a *aqueryArtifactHandler) normalActionBuildStatement(actionEntry *analysis_v2_proto.Action) (*BuildStatement, error) {
-	command := strings.Join(proptools.ShellEscapeListIncludingSpaces(actionEntry.Arguments), " ")
+	command := commandString(actionEntry)
 	inputDepsetHashes, err := a.depsetContentHashes(actionEntry.InputDepSetIds)
 	if err != nil {
 		return nil, err