Skip to content

Commit 2efefc0

Browse files
authored
Revert to previous version of escapeArg(). (#515)
This should fix Windows path escaping issues. Closes #511.
1 parent 4188a26 commit 2efefc0

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

common/utils/src/main/java/org/graalvm/buildtools/utils/NativeImageUtils.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,14 @@ public static List<String> convertToArgsFile(List<String> cliArgs, Path outputDi
105105
}
106106

107107

108-
/**
109-
* See https://github.com/oracle/graal/blob/f011d4d056a7ed78fe9669cc38062e6d09c14bed/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java#L1447C47-L1447C60.
110-
*/
111108
public static String escapeArg(String arg) {
112-
if (arg.isEmpty()) {
113-
return "''";
114-
}
115-
Matcher m = SAFE_SHELL_ARG.matcher(arg);
116-
if (m.matches()) {
117-
return arg;
109+
if (!(arg.startsWith("\\Q") && arg.endsWith("\\E"))) {
110+
arg = arg.replace("\\", "\\\\");
111+
if (arg.contains(" ")) {
112+
arg = "\"" + arg + "\"";
113+
}
118114
}
119-
return "'" + arg
120-
.replace("'", "'\"'\"'")
121-
.replace("\\", "\\\\") /* for Windows paths */
122-
+ "'";
115+
return arg;
123116
}
124117

125118

0 commit comments

Comments
 (0)