From 44d29a33df81ac07163d5146a9e43a0c4fb80af0 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 13 Sep 2020 22:06:40 -0400 Subject: new shell --- src/user/init/init.c | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'src/user/init') diff --git a/src/user/init/init.c b/src/user/init/init.c index e878603..fb231e0 100644 --- a/src/user/init/init.c +++ b/src/user/init/init.c @@ -2,19 +2,6 @@ #include #include -void start(const char *cmd) { - tell_user_sz("[init] Starting "); - tell_user_sz(cmd); - tell_user_sz(": "); - tell_user_sz( - run_command(cmd) - ? "Succeded.\n" - : "Failed.\n" - ); - tell_user_sz("[init] Yielding.\n"); - yield_task(); -} - #define STARTUP_FILE_PATH "sys/startup.rc" void main() { @@ -26,22 +13,17 @@ void main() { tell_user_sz("[init] Reading from " STARTUP_FILE_PATH ".\n"); - char buf[1024]; - char *bufp = buf; - while (read_from_file(f, 1, bufp)) { - if (*bufp == '\n') { - if (bufp == buf) - continue; - *bufp = '\0'; - start(buf); - bufp = buf; + char cmdbuf[128]; + while (read_line_from_file(f, cmdbuf, 127)) { + tell_user_sz("[init] Starting "); + tell_user_sz(cmdbuf); + tell_user_sz(": "); + if (run_command(cmdbuf)) { + tell_user_sz("Succeded.\n"); + yield_task(); } else - ++bufp; - } - if (bufp != buf) { - *bufp = '\0'; - start(buf); + tell_user_sz("Failed.\n"); } close_file(f); -- cgit v1.2.3