feature (shell): started work on a basic shell

This commit is contained in:
antifallobst 2023-05-02 00:39:54 +02:00
parent 99cd492570
commit ddc47b3ea3
2 changed files with 39 additions and 0 deletions

39
ramdisk/shell.c Normal file
View File

@ -0,0 +1,39 @@
#include "nox/stdio.h"
#define COMMAND_BUFFER_SIZE 512
int read_command(char* command_buffer) {
char chr = 0;
int pos = 0;
while (chr != '\n') {
chr = getc();
switch (chr) {
case '\b': {
if (pos > 0) pos--;
break;
}
default: {
if (pos < COMMAND_BUFFER_SIZE) {
command_buffer[pos] = chr;
pos++;
}
break;
}
}
}
command_buffer[pos] = '\0';
return pos;
}
void _start() {
printf("Welcome to the nox shell.\ntype 'help' for a list of commands\n");
bool running = true;
while(running) {
printf("\n>>> ");
char command_buffer[COMMAND_BUFFER_SIZE];
read_command(command_buffer);
}
}

BIN
ramdisk/shell.elf Executable file

Binary file not shown.