Skip to content

Commit

Permalink
Revert to previous version of escapeArg(). (#515)
Browse files Browse the repository at this point in the history
This should fix Windows path escaping issues.

Closes #511.
  • Loading branch information
fniephaus authored Oct 10, 2023
1 parent 4188a26 commit 2efefc0
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,14 @@ public static List<String> convertToArgsFile(List<String> cliArgs, Path outputDi
}


/**
* See https://github.com/oracle/graal/blob/f011d4d056a7ed78fe9669cc38062e6d09c14bed/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java#L1447C47-L1447C60.
*/
public static String escapeArg(String arg) {
if (arg.isEmpty()) {
return "''";
}
Matcher m = SAFE_SHELL_ARG.matcher(arg);
if (m.matches()) {
return arg;
if (!(arg.startsWith("\\Q") && arg.endsWith("\\E"))) {
arg = arg.replace("\\", "\\\\");
if (arg.contains(" ")) {
arg = "\"" + arg + "\"";
}
}
return "'" + arg
.replace("'", "'\"'\"'")
.replace("\\", "\\\\") /* for Windows paths */
+ "'";
return arg;
}


Expand Down

0 comments on commit 2efefc0

Please sign in to comment.