diff --git a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/util/ShellUtils.java b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/util/ShellUtils.java index e0efd3a912..7e4f09e6d0 100644 --- a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/util/ShellUtils.java +++ b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/util/ShellUtils.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -132,33 +132,27 @@ public class ShellUtils { if (args.isEmpty()) { return ""; } - StringBuilder line = new StringBuilder(args.get(0)); + StringBuilder line = new StringBuilder(genreateArgument(args.get(0))); for (int i = 1; i < args.size(); i++) { String a = args.get(i); - if (a.contains(" ")) { - if (a.contains("\"")) { - if (a.contains("'")) { - line.append(" \""); - line.append(a.replace("\"", "\\\"")); - line.append("\""); - continue; - } - line.append(" '"); - line.append(a); - line.append("'"); - continue; - } - line.append(" \""); - line.append(a); - line.append("\""); - continue; - } - line.append(" "); - line.append(a); + line.append(" " + genreateArgument(a)); } return line.toString(); } + public static String genreateArgument(String a) { + if (a.contains(" ")) { + if (a.contains("\"")) { + if (a.contains("'")) { + return "\"" + a.replace("\"", "\\\"") + "\""; + } + return "'" + a + "'"; + } + return "\"" + a + "\""; + } + return a; + } + public static String generateEnvBlock(Map env) { return env.entrySet() .stream()