aboutsummaryrefslogtreecommitdiff
path: root/src/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/command')
-rw-r--r--src/command/builtin.cc3
-rw-r--r--src/command/cd.cc19
2 files changed, 21 insertions, 1 deletions
diff --git a/src/command/builtin.cc b/src/command/builtin.cc
index 917dee4..4c5c1e2 100644
--- a/src/command/builtin.cc
+++ b/src/command/builtin.cc
@@ -13,7 +13,8 @@ unordered_map<string, function<void(char**)>> cmd =
{ "exit", ov4::command::exit },
{ "jobs", ov4::command::jobs },
{ "bg", ov4::command::bg },
- { "fg", ov4::command::fg }
+ { "fg", ov4::command::fg },
+ { "cd", ov4::command::cd },
};
/*
diff --git a/src/command/cd.cc b/src/command/cd.cc
new file mode 100644
index 0000000..49b1899
--- /dev/null
+++ b/src/command/cd.cc
@@ -0,0 +1,19 @@
+#include "command/builtin.h"
+
+namespace ov4::command
+{
+
+using namespace std;
+
+void cd(char **argv)
+{
+ if (argv == nullptr) return;
+ if (argv[1] == nullptr)
+ {
+ cout << "cd: requires path" << endl;
+ return;
+ }
+ ov4::set_current_dir(argv[1]);
+}
+
+}