Quoting arguments

I am working with the Synergy plugin sources and porting the existing Windows-only plugin to Linux.
The one remaining issue deals with quoted arguments that get passed to Synergy whenever a Synergy
command is selected from the IntelliJ menus.

More specifically, any Synergy command that contains an argument that needs to be quoted (i.e., check
out has a comment argument, create task has the synopsis and description arguments. When debugging
the plugin's execution, I see the correct quoting being sent to the SHELL, but somewhere in the
transmission, the quoting gets discarded.

I've tried almost every combination of escaping quotes to get around this, but nothing is working.

Any suggestions? Any alternatives to the Runtime.getInstance().exec command that may better handle
quoting issues? Otherwise, I think there is a bug in the handling of formats inside MessageFormat.

The code snippet construction the command uses:

public static final String CMD_CHECKOUTFILE = "checkout -comment \"\" -task ";

public String[] executeCommand(String cmd, Object[] obj) {

StringBuffer command = new StringBuffer().append(config.propPathToCCM).append(File.separatorChar).
append(CCM).append(MessageFormat.format(cmd, obj));

try {

Process p = Runtime.getRuntime().exec(command.toString());

try {
catch (InterruptedException e)


And it's called via:

public void checkOutFile(String fileName, CMSynergyTask task)

String[] res = this.executeCommand(CMD_CHECKOUTFILE,
new Object[]{"Checked out for task: " + task.getId(), task.getId(), fileName});


Please sign in to leave a comment.