CE add quit command
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m38s

This commit is contained in:
2026-02-25 16:32:11 +01:00
parent 2052bb0e1d
commit 4e09296709

16
ce/ce.c
View File

@@ -25,6 +25,8 @@ struct token {
static int e_pid;
static int e_pgid;
static bool run = true;
static void putch (char ch) { mail_send (e_pgid, &ch, 1); }
void putchar_ (char ch) { putch (ch); }
@@ -148,14 +150,18 @@ static void cmd_ls (struct list_node_link* tokens) {
volume_close ();
}
static void cmd_help (struct list_node_link* tokens) {
(void)tokens;
static void cmd_quit (void) {
run = false;
printf ("Goodbye!\n");
}
static void cmd_help (void) {
printf ("Available commands:\n");
printf ("echo <word1> <word2> <word3> ...\n");
printf ("help\n");
printf ("cat <file path>\n");
printf ("ls <directory path>\n");
printf ("quit\n");
}
static void exec_tokens (struct list_node_link* tokens) {
@@ -164,11 +170,13 @@ static void exec_tokens (struct list_node_link* tokens) {
if (strcmp (cmd_token->buffer, "echo") == 0) {
cmd_echo (tokens->next);
} else if (strcmp (cmd_token->buffer, "help") == 0) {
cmd_help (tokens->next);
cmd_help ();
} else if (strcmp (cmd_token->buffer, "cat") == 0) {
cmd_cat (tokens->next);
} else if (strcmp (cmd_token->buffer, "ls") == 0) {
cmd_ls (tokens->next);
} else if (strcmp (cmd_token->buffer, "quit") == 0) {
cmd_quit ();
} else {
printf ("ERROR: unknown command '%s'\n", cmd_token->buffer);
}
@@ -193,7 +201,7 @@ void app_main (void) {
char line_buffer[LINE_BUFFER_MAX + 1];
memset (line_buffer, 0, sizeof (line_buffer));
for (;;) {
while (run) {
printf (PROMPT);
char ch = 0;