forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringProcessor.java
More file actions
30 lines (23 loc) · 802 Bytes
/
StringProcessor.java
File metadata and controls
30 lines (23 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.function.Function;
public class StringProcessor {
private static final Processor<String> processor = new Processor<String>();
public static void main(String[] args) {
String command = args[0];
lambdaExec(command);
}
public static void lambdaExec(String command){
processor.process(s->exec(s), command);
}
public static String lambdaUnrelated(String command){
return processor.process(s->s+"not related to anything", command);
}
public static String exec(String command){
try {
command = processor.process(s->s.trim(), command);
Runtime.getRuntime().exec(command);
return "Executed: "+command;
} catch(Exception e) {
return null;
}
}
}