Skip to content

Commit

Permalink
Merge pull request #13 from jacobgardner/master
Browse files Browse the repository at this point in the history
Use list instead of string for ProcessBuilder For External Deletion Tools
  • Loading branch information
vjuranek committed Oct 8, 2013
2 parents 16ae770 + f6b776f commit ffb4364
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/hudson/plugins/ws_cleanup/Cleanup.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ public Object invoke(File f, VirtualChannel channel) throws IOException, Interru
if (delete_command != null && patterns == null) {
temp_command = delete_command.replaceAll("%s", "\"" + StringEscapeUtils.escapeJava(f.getPath()) + "\"");
this.listener.getLogger().println("Using command: " + temp_command);
Process deletion_proc = new ProcessBuilder(temp_command).start();
List<String> list = new ArrayList<String>();

java.util.regex.Pattern p = java.util.regex.Pattern.compile("\"[^\"]+\"|\\S+");
java.util.regex.Matcher m = p.matcher(temp_command);

while(m.find()) {
list.add(m.group());
}

Process deletion_proc = new ProcessBuilder(list).start();
deletion_proc.waitFor();

return null;
Expand Down

0 comments on commit ffb4364

Please sign in to comment.