org.hidetake.groovy.ssh.session.execution.Escape.groovy Maven / Gradle / Ivy
package org.hidetake.groovy.ssh.session.execution
/**
* Shell escape utility.
*
* @author Hidetake Iwata
*/
class Escape {
/**
* Escape command arguments.
* This method quotes each argument with single-quote.
* @param arguments
* @return
*/
static String escape(List arguments) {
arguments.collect { /'${it.replaceAll(~/'/, /'\\''/)}'/ }.join(/ /)
}
}