summaryrefslogtreecommitdiff
path: root/src/user/app/shell/shell.c
diff options
context:
space:
mode:
authordzwdz2022-08-08 19:04:27 +0200
committerdzwdz2022-08-08 19:04:27 +0200
commitf2703089da21898e9c3127615e98c1717c7ceeb5 (patch)
treed4a80164a20b34cbf594e72d758708be23c0e6e1 /src/user/app/shell/shell.c
parenta4634ea9458fcc4856ad52bcf383efcb9134091f (diff)
user/libc: cwd
Diffstat (limited to 'src/user/app/shell/shell.c')
-rw-r--r--src/user/app/shell/shell.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c
index d96ef4c..0f97d7a 100644
--- a/src/user/app/shell/shell.c
+++ b/src/user/app/shell/shell.c
@@ -47,6 +47,11 @@ void run_args(int argc, char **argv, struct redir *redir) {
exit(1);
}
return;
+ } else if (!strcmp(argv[0], "cd")) {
+ if (chdir(argc > 1 ? argv[1] : "/") < 0)
+ eprintf("error");
+ // TODO strerror
+ return;
} else if (!strcmp(argv[0], "time")) {
uint64_t time = __rdtsc();
uint64_t div = 3000;
@@ -148,7 +153,7 @@ int main(int argc, char **argv) {
for (;;) {
if (f == stdin)
- printf("$ ");
+ printf("%s $ ", getcwd(buf, sizeof buf));
if (!fgets(buf, 256, f))
return 0;
run(buf);