@Test public void testUnix() { StringBuilder buffer; buffer = new StringBuilder(); addEscapedArgumentOnUnix(buffer, "abc"); assertThat(buffer.toString(), is("'abc'")); buffer = new StringBuilder(); addEscapedArgumentOnUnix(buffer, "a'b'c"); assertThat(buffer.toString(), is("'a'\\''b'\\''c'")); buffer = new StringBuilder(); addEscapedArgumentOnUnix(buffer, "'abc'"); assertThat(buffer.toString(), is("\\''abc'\\'")); }
public static void addEscapedArgumentOnUnix(StringBuilder buffer, String arg) { if (buffer.length() > 0) buffer.append(' '); boolean quoted = false; Matcher matcher = RE_U.matcher(arg); while (matcher.find()) { String matched = matcher.group(); char c = matched.charAt(0); if (c == '\'') { if (quoted) { buffer.append('\''); quoted = false; } buffer.append("\\'"); } else { if (!quoted) { buffer.append('\''); quoted = true; } buffer.append(matched); } } if (quoted) buffer.append('\''); }
CommandLineUtils { public static void addEscapedArgumentOnUnix(StringBuilder buffer, String arg) { if (buffer.length() > 0) buffer.append(' '); boolean quoted = false; Matcher matcher = RE_U.matcher(arg); while (matcher.find()) { String matched = matcher.group(); char c = matched.charAt(0); if (c == '\'') { if (quoted) { buffer.append('\''); quoted = false; } buffer.append("\\'"); } else { if (!quoted) { buffer.append('\''); quoted = true; } buffer.append(matched); } } if (quoted) buffer.append('\''); } }
CommandLineUtils { public static void addEscapedArgumentOnUnix(StringBuilder buffer, String arg) { if (buffer.length() > 0) buffer.append(' '); boolean quoted = false; Matcher matcher = RE_U.matcher(arg); while (matcher.find()) { String matched = matcher.group(); char c = matched.charAt(0); if (c == '\'') { if (quoted) { buffer.append('\''); quoted = false; } buffer.append("\\'"); } else { if (!quoted) { buffer.append('\''); quoted = true; } buffer.append(matched); } } if (quoted) buffer.append('\''); } private  CommandLineUtils(); }
CommandLineUtils { public static void addEscapedArgumentOnUnix(StringBuilder buffer, String arg) { if (buffer.length() > 0) buffer.append(' '); boolean quoted = false; Matcher matcher = RE_U.matcher(arg); while (matcher.find()) { String matched = matcher.group(); char c = matched.charAt(0); if (c == '\'') { if (quoted) { buffer.append('\''); quoted = false; } buffer.append("\\'"); } else { if (!quoted) { buffer.append('\''); quoted = true; } buffer.append(matched); } } if (quoted) buffer.append('\''); } private  CommandLineUtils(); static void addEscapedArgumentOnWindows(StringBuilder buffer, String arg); static void addEscapedArgumentOnUnix(StringBuilder buffer, String arg); static String espaceCommandLineArgs(String[] args); }
CommandLineUtils { public static void addEscapedArgumentOnUnix(StringBuilder buffer, String arg) { if (buffer.length() > 0) buffer.append(' '); boolean quoted = false; Matcher matcher = RE_U.matcher(arg); while (matcher.find()) { String matched = matcher.group(); char c = matched.charAt(0); if (c == '\'') { if (quoted) { buffer.append('\''); quoted = false; } buffer.append("\\'"); } else { if (!quoted) { buffer.append('\''); quoted = true; } buffer.append(matched); } } if (quoted) buffer.append('\''); } private  CommandLineUtils(); static void addEscapedArgumentOnWindows(StringBuilder buffer, String arg); static void addEscapedArgumentOnUnix(StringBuilder buffer, String arg); static String espaceCommandLineArgs(String[] args);  }