diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-30 00:06:31 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-30 00:06:31 +0100 |
commit | 0f20be05a6fafa430702ab48dc264bbc2cea1fd3 (patch) | |
tree | e865e535b78f2e14da05c8052daeab8bc41807ac /Userland/sh.cpp | |
parent | 8e640539ef33de68697c48d4bfb76f1d2ba7a709 (diff) | |
download | serenity-0f20be05a6fafa430702ab48dc264bbc2cea1fd3.zip |
Implement sys$getcwd properly.
Also fixed broken strcpy that didn't copy the null terminator.
Diffstat (limited to 'Userland/sh.cpp')
-rw-r--r-- | Userland/sh.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Userland/sh.cpp b/Userland/sh.cpp index e501ec02f8..3592587078 100644 --- a/Userland/sh.cpp +++ b/Userland/sh.cpp @@ -164,7 +164,11 @@ int main(int, char**) printf("failed to open /dev/keyboard :(\n"); return 1; } - g->cwd = "/"; + { + char cwdbuf[1024]; + getcwd(cwdbuf, sizeof(cwdbuf)); + g->cwd = cwdbuf; + } prompt(); for (;;) { char keybuf[16]; @@ -173,12 +177,6 @@ int main(int, char**) printf("failed to read :(\n"); return 2; } - if (nread > 2) - printf("read %u bytes\n", nread); - if (nread > (ssize_t)sizeof(keybuf)) { - printf("read() overran the buffer i gave it!\n"); - return 3; - } for (ssize_t i = 0; i < nread; ++i) { putchar(keybuf[i]); if (keybuf[i] != '\n') { |