Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-5015: post-review GP-5015: fix for spaces issue

d-millar100958880bba
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/ScriptAttributesParser.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/ScriptAttributesParser.java
index 2722740ec3..647b5a2c08 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/ScriptAttributesParser.java
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/ScriptAttributesParser.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* 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
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
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 60731e9359..209cfa1202 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
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* 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
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -127,31 +127,25 @@ 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(" " + genreateArgument(a));
+ }
+ return line.toString();
+ }
+
+ public static String genreateArgument(String a) {
+ if (a.contains(" ")) {
+ if (a.contains("\"")) {
+ if (a.contains("'")) {
+ return "\"" + a.replace("\"", "\\\"") + "\"";
}
- line.append(" \"");
- line.append(a);
- line.append("\"");
- continue;
+ return "'" + a + "'";
}
- line.append(" ");
- line.append(a);
+ return "\"" + a + "\"";
}
- return line.toString();
+ return a;
}
public static String generateEnvBlock(Map<String, String> env) {