From ddc47b3ea393b17e939ca959ed0b7223933436b1 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Tue, 2 May 2023 00:39:54 +0200 Subject: [PATCH] feature (shell): started work on a basic shell --- ramdisk/shell.c | 39 +++++++++++++++++++++++++++++++++++++++ ramdisk/shell.elf | Bin 0 -> 17992 bytes 2 files changed, 39 insertions(+) create mode 100644 ramdisk/shell.c create mode 100755 ramdisk/shell.elf diff --git a/ramdisk/shell.c b/ramdisk/shell.c new file mode 100644 index 0000000..b1cd05c --- /dev/null +++ b/ramdisk/shell.c @@ -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); + } +} \ No newline at end of file diff --git a/ramdisk/shell.elf b/ramdisk/shell.elf new file mode 100755 index 0000000000000000000000000000000000000000..5599c106495b0db4779b4bb41c19ba5d6dbcb64e GIT binary patch literal 17992 zcmeHPYj7LI9p63aWcd+Wi4Ac`APTQQi)F`z@JdV+>l}&5vMbvm87POWhowfATsJeSB!=cINKC`+x0!f4h5od%DwuTCh*yoXKQkJ&a0YE|arf2%KJ#0a?#(V2wCm zz}lDtWxK&MZ0Zzz8z|X*Q^;%SGNC7_jF2eV&6ie?V2b5jB$aj)#`)MuJP8vzek$5g zOD`AoNlLnu22U1Zl=r!*bS@n>*-TPt_ZiqxoS!sF*u$c}Pl}6xmvyF7qia@orehuH zRHnGSWBUzjI@YZAp?;$_( z_@psgdKLl}0u}-m0u}-m0u}-m0u}-m0u}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