Skip to content

Commit

Permalink
Use list instead of string for ProcessBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Gardner committed Oct 7, 2013
1 parent 16ae770 commit f6b776f
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 f6b776f

Please sign in to comment.