### Question:
StringUtil { public static String escapeShell(String arg, OS os) { if (os.isPosix) { return "'" + StringUtils.replace(arg, "'", "'\\''") + "'"; } else if (os == OS.WINDOWS) { return '"' + StringUtils.replace(arg, "\"", "\\\"") + '"'; } throw new IllegalArgumentException("unsupported OS"); }  static String unquoteCString(String str); static String unquoteCString(String str, char delimiter); static String makeProper(String str); static String enquoteCString(String value); static String enquoteCString(String value, char delimiter); static void throwIfSurrogatePair(int codePoint); static int lastIndexOfAny(String str, String search, int offset); static int indexOfAny(String str, String search, int offset); static String unquoteKString(String str); static String enquoteKString(String value); static String getCategoryCode(byte cat); static String getDirectionalityCode(byte cat); static String escapeSort(NonTerminal nonTerminal); static String escapeSort(Sort sort); static String escapeSort(String str); static String unEscapeSortName(String str); static String getSortNameFromCons(String str); static String escapeMaude(String tag); static String unescapeMaude(String str); static String latexify(String name); static String emptyIfNull(String string); static int getStartLineFromLocation(String location); static int getStartColFromLocation(String location); static String splitLines(String str); static String splitLines(String str, final int col); static String[] finesseJCommanderUsage(String string, JCommander jc); static String escapeShell(String arg, OS os); static String escapeShell(String[] args, OS os);  }### Answer:
@Test public void StringUtilEscapeShell() throws Exception { String[] cmd1 = new String[] {"foo", "bar \" baz"}; String[] cmd2 = new String[] {"'"}; Assert.assertEquals("\"foo\" \"bar \\\" baz\"", StringUtil.escapeShell(cmd1, OS.WINDOWS)); Assert.assertEquals("'foo' 'bar \" baz'", StringUtil.escapeShell(cmd1, OS.LINUX)); Assert.assertEquals("''\\'''", StringUtil.escapeShell(cmd2, OS.LINUX)); }