aboutsummaryrefslogtreecommitdiff
path: root/smash/builtin.c
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2022-12-15 21:17:41 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2022-12-15 21:17:41 +0100
commit02062f0cf84e1cb7fb294de54b0c00db6323c529 (patch)
treec71b34ef1ffdeb95fabc0ec10516d13b81984309 /smash/builtin.c
parent828dd435725ea315abd2ea9875325ee3b17041a9 (diff)
add 'cd' to smash
Diffstat (limited to 'smash/builtin.c')
-rw-r--r--smash/builtin.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/smash/builtin.c b/smash/builtin.c
index ad9c839..63a4013 100644
--- a/smash/builtin.c
+++ b/smash/builtin.c
@@ -3,6 +3,7 @@
#include "../lib/sys/exit.h"
#include "../lib/cstr/cstr.h"
#include "../lib/sys/io.h"
+#include "../lib/sys/chdir.h"
u64 __find_builtin_function_by_name(const char *name);
@@ -30,7 +31,12 @@ int __builtin_fn_exit(int argc, const char **argv)
int __builtin_fn_cd(int argc, const char **argv)
{
- /* TODO: Implement */
+ if (argc != 2) {
+ write(STDOUT_FD, "path missing\n", 9);
+ return -1;
+ }
+
+ return chdir(argv[1]);
}
int __builtin_fn_help(int argc, const char **argv)