void ( @NotNull String command, @NotNull List<@NotNull String> parameters, @NotNull List<? super @NotNull String> commandLine ) { boolean isCmdParam = isWinShell(command); int cmdInvocationDepth = isWinShellScript(command) ? 2 : isCmdParam ? 1 : 0; QuoteFlag quoteFlag = new QuoteFlag(false); for (int i = 0; i < parameters.size(); i++) { String parameter = parameters.get(i); parameter = StringUtilRt.unquoteString(parameter, INESCAPABLE_QUOTE); boolean inescapableQuoting = !parameter.equals(parameters.get(i)); if (parameter.isEmpty()) { commandLine.add(QQ); continue; } if (isCmdParam && parameter.startsWith("/") && parameter.length() == 2) { commandLine.add(parameter); continue; } String parameterPrefix = ""; if (isCmdParam) { Matcher m = WIN_QUIET_COMMAND.matcher(parameter); if (m.matches()) { parameterPrefix = m.group(1); // @... parameter = m.group(2); } if (parameter.equalsIgnoreCase("echo")) { // no further quoting, only ^-escape and wrap the whole "echo ..." into double quotes String parametersJoin = String.join(" ", parameters.subList(i, parameters.size())); quoteFlag.toggle(); parameter = escapeParameter(parametersJoin, quoteFlag, cmdInvocationDepth, false); commandLine.add(parameter); // prefix is already included break; } if (!parameter.equalsIgnoreCase("call")) { isCmdParam = isWinShell(parameter); if (isCmdParam || isWinShellScript(parameter)) { cmdInvocationDepth++; } } } if (cmdInvocationDepth > 0 && !isCmdParam || inescapableQuoting) { parameter = escapeParameter(parameter, quoteFlag, cmdInvocationDepth, !inescapableQuoting); } else { parameter = backslashEscapeQuotes(parameter); } commandLine.add(parameterPrefix.isEmpty() ? parameter : parameterPrefix + parameter); } }