-
Notifications
You must be signed in to change notification settings - Fork 2
/
shell.cfm
executable file
·52 lines (47 loc) · 1.12 KB
/
shell.cfm
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<cfscript>
System = createObject("java", "java.lang.System");
InputStreamReader = createObject("java","java.io.InputStreamReader");
BufferedReader = createObject("java","java.io.BufferedReader");
br = BufferedReader.init(InputStreamReader.init(System.in));
keepRunning = true;
script = "";
while (keepRunning) {
systemOutput("cfml: ");
while(isNull(inLine)) {
inLine = br.readLine();
}
args = inLine.split(" ");
switch(args[1]) {
case "clear":
script = "";
break;
case "dir": case "ls":
dir = isNull(args[2]) ? "." : args[2];
for(dir in directoryList(dir)) {
systemOutput(dir);
}
break;
case "exit": case "quit": case "q":
systemOutput("Peace out!");
keepRunning = false;
break;
case "":
try{
systemOutput(script);
systemOutput(evaluate(script));
} catch (any e) {
systemOutput("error: " & e.message);
}
break;
default:
try{
systemOutput(inLine & " = " & evaluate(inLine));
script &= inLine;
} catch (any e) {
systemOutput("error: " & e.message);
}
break;
}
inLine = javaCast("null","");
}
</cfscript>