summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-30 00:06:31 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-10-30 00:06:31 +0100
commit0f20be05a6fafa430702ab48dc264bbc2cea1fd3 (patch)
treee865e535b78f2e14da05c8052daeab8bc41807ac /Userland
parent8e640539ef33de68697c48d4bfb76f1d2ba7a709 (diff)
downloadserenity-0f20be05a6fafa430702ab48dc264bbc2cea1fd3.zip
Implement sys$getcwd properly.
Also fixed broken strcpy that didn't copy the null terminator.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/sh.cpp12
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') {