From f2703089da21898e9c3127615e98c1717c7ceeb5 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 8 Aug 2022 19:04:27 +0200 Subject: user/libc: cwd --- src/user/app/shell/shell.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/user/app/shell/shell.c') 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); -- cgit v1.2.3