com.intellij.util.execution.ParametersListUtil escapes special symbols: "" and \


The Bazel plugin for Intellij products uses com.intellij.util.execution.ParametersListUtil to get the command line in order to show an executed command in a terminal. The command is defined in the Java code as the following:

return String.format("attr(\\\"tags\\\", \\\"^((?!manual).)*$\\\", %s)", targets);

So I wish to get "tags" in escaped quotas: \"tags\".

And the log message is formed as the following:

String logMessage =
"Command: " + ParametersListUtil.join(command) + SystemProperties.getLineSeparator();

But it looks like the ParameterListUtil class adds extra slashes when it is joining commands and a user sees the following log message:

Command: bazel query --tool_tag=ijwb:CLion --output=label_kind --keep_going "attr(\\"tags\\", \\"^((?!manual).)*$\\", //demos/...:all + //lib/...:all + //mkl/...:all + //test/...:all)" --

But the command exactly has NOT this double slashes attr(\\"tags\\" , it has only one slash: attr(\"tags\" and if I just copy the command into the terminal and run it, an error will be generated.

I use the version of the API that is shipped with Clion EAP 193.5096.27. I'm absolutely newbie in Idea plugin development and I have no idea whether this extra-escaping in console output is a best practice. As a user I definitely wish to see the command that will be exactly executed.

Should I use com.intellij.util.execution.ParametersListUtil to form an output message or it is better just to replace it with String.join(" ", command)?



Hi, class `ParametersListUtil` was created to handle characters that must be escaped. You should either pass unescaped command or not to use this class (to avoid double escaping). 


Andrey Vokin Thank you! Now I know how to get on the screen what exactly I do.


Please sign in to leave a comment.