mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
Added support for nested quotes in arguments when calling external commands from Cooja
This commit is contained in:
parent
24dba740e2
commit
c425e51911
@ -43,7 +43,6 @@ import java.io.InputStreamReader;
|
|||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
@ -89,11 +88,15 @@ public class CompileContiki {
|
|||||||
final MessageList compilationOutput,
|
final MessageList compilationOutput,
|
||||||
boolean synchronous)
|
boolean synchronous)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Pattern p = Pattern.compile("([^\\s\"']|\"[^\"]*\"|'[^']*')+");
|
Pattern p = Pattern.compile("([^\\s\"']+|\"[^\"]*\"|'[^']*')");
|
||||||
Matcher m = p.matcher(command);
|
Matcher m = p.matcher(command);
|
||||||
ArrayList<String> commandList = new ArrayList<String>();
|
ArrayList<String> commandList = new ArrayList<String>();
|
||||||
while(m.find()) {
|
while(m.find()) {
|
||||||
commandList.add(m.group().replaceAll("['\"]",""));
|
String arg = m.group();
|
||||||
|
if (arg.length() > 1 && (arg.charAt(0) == '"' || arg.charAt(0) == '\'')) {
|
||||||
|
arg = arg.substring(1, arg.length() - 1);
|
||||||
|
}
|
||||||
|
commandList.add(arg);
|
||||||
}
|
}
|
||||||
return compile(commandList.toArray(new String[commandList.size()]), env, outputFile, directory, onSuccess, onFailure, compilationOutput, synchronous);
|
return compile(commandList.toArray(new String[commandList.size()]), env, outputFile, directory, onSuccess, onFailure, compilationOutput, synchronous);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user