diff --git a/bin/shell/shell.c b/bin/shell/shell.c index 5da08ed..9c59ffd 100644 --- a/bin/shell/shell.c +++ b/bin/shell/shell.c @@ -37,6 +37,23 @@ Cmd_Help(int argc, const char *argv[]) printf("help Display the list of commands\n"); } +void +Cmd_Exit(int argc, const char *argv[]) +{ + int val = 0; + + if (argc != 1 && argc != 2) { + printf("Invalid number of arguments\n"); + return; + } + + if (argc == 2) { + val = atoi(argv[1]); + } + + exit(val); +} + const char *searchpath[] = { "", "/sbin/", @@ -112,7 +129,7 @@ DispatchCommand(char *buf) } else if (strcmp(argv[0], "bkpt") == 0) { asm volatile("int3"); } else if (strcmp(argv[0], "exit") == 0) { - exit(0); + Cmd_Exit(argc, (const char **)argv); } else if (strcmp(argv[0], "#") == 0) { // Ignore comments } else if (buf[0] == '\0') {