diff options
Diffstat (limited to 'Source/Applications/Shell')
-rw-r--r-- | Source/Applications/Shell/Help.txt | 16 | ||||
-rw-r--r-- | Source/Applications/Shell/Makefile | 2 | ||||
-rw-r--r-- | Source/Applications/Shell/Shell.ns.cpp | 38 | ||||
-rw-r--r-- | Source/Applications/Shell/Shell.ns.h | 1 |
4 files changed, 56 insertions, 1 deletions
diff --git a/Source/Applications/Shell/Help.txt b/Source/Applications/Shell/Help.txt new file mode 100644 index 0000000..c1209cf --- /dev/null +++ b/Source/Applications/Shell/Help.txt @@ -0,0 +1,16 @@ + ** Command list for Melon's shell ** + + Command Description Required groups + - help shows this + - reboot reboots your computer root + - halt shuts down your computer root + - loadkeys loads a new keymap root + - free shows free amount of RAM + - uptime shows computer's uptime + - run runs a binary file + - wf writes text to a file + +The shell also supports basic UNIX-like commands : + ls, cd, cat, pwd, rm, mkdir + +The terminal supports scrolling with shift+{up,pgdown,pgup} diff --git a/Source/Applications/Shell/Makefile b/Source/Applications/Shell/Makefile index b33b067..f93d80d 100644 --- a/Source/Applications/Shell/Makefile +++ b/Source/Applications/Shell/Makefile @@ -16,7 +16,7 @@ all: $(OutFile) rebuild: mrproper all $(OutFile): $(Objects) - echo "* Linking $@.o..." + echo "* Linking $@..." $(LD) $(LDFLAGS) ../../Library/Melon.o $^ -o $@ %.o: %.cpp diff --git a/Source/Applications/Shell/Shell.ns.cpp b/Source/Applications/Shell/Shell.ns.cpp index e2433cb..d34f516 100644 --- a/Source/Applications/Shell/Shell.ns.cpp +++ b/Source/Applications/Shell/Shell.ns.cpp @@ -1,4 +1,5 @@ #include "Shell.ns.h" +#include <Binding/Sys.ns.h> namespace Shell { @@ -9,7 +10,44 @@ u32int run() { while (1) { outvt << node.getName() << " : "; String s = invt.readLine(); + while (s[0] == WChar(" ") or s[0] == WChar("\t")) { + s = s.substr(1, s.size() - 1); + } + if (s[0] == WChar("#")) continue; + if (s.empty()) continue; + + //Parse string + Vector<String> cmd; + cmd.push(String()); + bool inQuote = false; + for (u32int i = 0; i < s.size(); i++) { + if (s[i] == WChar("'")) { + inQuote = !inQuote; + } else if (s[i] == WChar("\\")) { + i++; + cmd.back() += s[i]; + } else if (s[i] == WChar(" ") and !inQuote) { + cmd.push(String()); + } else { + cmd.back() += s[i]; + } + } + + //Run command + if (cmd[0] == "exit") { + if (cmd.size() == 1) return 0; + return cmd[1].toInt(); + } else if (cmd[0] == "halt") { + Sys::halt(); + outvt << "Something went wrong.\n"; + } else if (cmd[0] == "reboot") { + Sys::reboot(); + outvt << "Something went wrong.\n"; + } else { + } } } } + + diff --git a/Source/Applications/Shell/Shell.ns.h b/Source/Applications/Shell/Shell.ns.h index 7d76b33..3be1e0d 100644 --- a/Source/Applications/Shell/Shell.ns.h +++ b/Source/Applications/Shell/Shell.ns.h @@ -6,4 +6,5 @@ namespace Shell { u32int run(); extern FSNode cwd; + } |