-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbash.js
44 lines (36 loc) · 983 Bytes
/
bash.js
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
const pwd = require("./pwd");
const ls = require("./ls");
const cat = require("./cat");
const curl = require("./curl");
const date = require ("./date");
const echo = require("./echo");
const wc = require("./wc")
process.stdout.write("prompt > ");
process.stdin.on("data", (data) => {
const cmd = data.toString().trim().split(" ")[0];
const arg = data.toString().trim().split(" ")[1];
if (cmd === "pwd") {
pwd();
} else if (cmd === "ls") {
ls();
} else if (cmd === "cat") {
cat(arg);
} else if (cmd === 'curl') {
curl(arg);
} else if (cmd === 'date') {
date();
} else if (cmd === 'echo') {
echo(arg);
} else if (cmd === 'head') {
} else if (cmd === 'tail') {
} else if (cmd === 'sort') {
} else if (cmd === 'wc') {
wc(arg);
} else if (cmd === 'uniq') {
} else if (cmd === 'find') {
}
else {
process.stdout.write(cmd + " not found");
process.stdout.write("\nprompt > ");
}
});