Command line arguments with comma must be quoted on windows

This commit is contained in:
Tanguy Leroux 2016-04-01 14:44:13 +02:00
parent 283eff13aa
commit c739d9af2b
1 changed files with 15 additions and 1 deletions

View File

@ -391,6 +391,17 @@ class ClusterFormationTasks {
return configureExecTask(name, project, setup, node, args)
}
/** Surround strings that contains a comma with double quotes **/
private static String escapeComma(Object o) {
if (o instanceof String) {
String s = (String)o
if (s.indexOf(',') != -1) {
return "\"${s}\""
}
}
return o
}
/** Adds a task to execute a command to help setup the cluster */
static Task configureExecTask(String name, Project project, Task setup, NodeInfo node, Object[] execArgs) {
return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) {
@ -398,10 +409,13 @@ class ClusterFormationTasks {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
executable 'cmd'
args '/C', 'call'
// On Windows the comma character is considered a parameter separator:
// argument that contains a comma must be quoted
args execArgs.collect { a -> escapeComma(a) }
} else {
executable 'sh'
args execArgs
}
args execArgs
}
}