Allow shell exit to take an argument

This commit is contained in:
Ali Mashtizadeh 2023-10-02 19:42:20 -04:00
parent fb3348128e
commit 9864ede62c

View File

@ -37,6 +37,23 @@ Cmd_Help(int argc, const char *argv[])
printf("help Display the list of commands\n"); 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[] = { const char *searchpath[] = {
"", "",
"/sbin/", "/sbin/",
@ -112,7 +129,7 @@ DispatchCommand(char *buf)
} else if (strcmp(argv[0], "bkpt") == 0) { } else if (strcmp(argv[0], "bkpt") == 0) {
asm volatile("int3"); asm volatile("int3");
} else if (strcmp(argv[0], "exit") == 0) { } else if (strcmp(argv[0], "exit") == 0) {
exit(0); Cmd_Exit(argc, (const char **)argv);
} else if (strcmp(argv[0], "#") == 0) { } else if (strcmp(argv[0], "#") == 0) {
// Ignore comments // Ignore comments
} else if (buf[0] == '\0') { } else if (buf[0] == '\0') {