X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fexamples%2Fshell.c;h=93641b45b8c3250ff3dd3582fc731668d34ebbe7;hb=386e9fe63fef23415cc41bb325b1f19eb3d8184c;hp=d31eb3a9a67c534199f0731165295e0a117b1b7e;hpb=615bf3b3d2a8573ed6fb9ddc0055745e163ac999;p=pintos-anon diff --git a/src/examples/shell.c b/src/examples/shell.c index d31eb3a..93641b4 100644 --- a/src/examples/shell.c +++ b/src/examples/shell.c @@ -21,6 +21,11 @@ main (void) /* Execute command. */ if (!strcmp (command, "exit")) break; + else if (!memcmp (command, "cd ", 3)) + { + if (!chdir (command + 3)) + printf ("\"%s\": chdir failed\n", command + 3); + } else if (command[0] == '\0') { /* Empty command. */ @@ -36,7 +41,7 @@ main (void) } printf ("Shell exiting."); - return 0; + return EXIT_SUCCESS; } /* Reads a line of input from the user into LINE, which has room @@ -54,7 +59,7 @@ read_line (char line[], size_t size) switch (c) { - case '\n': + case '\r': *pos = '\0'; putchar ('\n'); return;