almost got the term emu working and shell

This commit is contained in:
2026-07-08 21:15:30 -05:00
parent ec3cbb4794
commit 4d98d73f5e
20 changed files with 214 additions and 228 deletions

View File

@@ -1,46 +1,13 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
const char* shell_prompt = "rocksh> ";
static void process_cmd(const char* cmd) {
size_t cmd_len = strlen(cmd);
if (cmd_len < 1) {
return;
}
if (strcmp(cmd, "exit") == 0) {
printf("bye!\n");
exit(0);
}
printf("command not recognized: %s\n", cmd);
}
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
char cmd[128];
size_t p = 0;
printf("%s", shell_prompt);
printf(shell_prompt);
while (1) {
char c = getchar();
printf("%c", c);
if (c != '\n') {
cmd[p++] = c;
continue;
}
cmd[p] = 0;
process_cmd(cmd);
memset(cmd, 0, 128);
p = 0;
printf("%s", shell_prompt);
}
return 0;
return 3;
}